當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ImageManager::rotateImage方法代碼示例

本文整理匯總了PHP中ImageManager::rotateImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImageManager::rotateImage方法的具體用法?PHP ImageManager::rotateImage怎麽用?PHP ImageManager::rotateImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ImageManager的用法示例。


在下文中一共展示了ImageManager::rotateImage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: rotatePicture

 /**
  * Rotates an image clockwise by 90�
  *
  * @global    ADONewConnection
  * @global    array
  * @global    array
  */
 function rotatePicture($intImageId)
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     if (!function_exists('imagerotate')) {
         $this->strErrMessage = $_ARRAYLANG['TXT_GALLERY_GD_LIB_NOT_INSTALLED'];
         return false;
     }
     $objResult = $objDatabase->Execute('SELECT     path,
                                                 quality,
                                                 size_type,
                                                 size_proz,
                                                 size_abs_h,
                                                 size_abs_w
                                         FROM     ' . DBPREFIX . 'module_gallery_pictures
                                         WHERE     id=' . $intImageId);
     $strImagename = $objResult->fields['path'];
     $strOrgPath = $this->strImagePath;
     $strWebpath = $this->strImageWebPath;
     $strThumbPath = $this->strThumbnailPath;
     $strThumbWebpath = $this->strThumbnailWebPath;
     $objImage = new \ImageManager();
     $objImage->loadImage($strOrgPath . $strImagename);
     //Rotate the clockwise
     if ($objImage->rotateImage(270)) {
         //To save the Rotated image
         if ($objImage->saveNewImage($strOrgPath . $strImagename, true)) {
             \Cx\Lib\FileSystem\FileSystem::delete_file($strThumbPath . $strImagename);
         }
         $imageSize = $objImage->_getImageSize($strOrgPath . $strImagename);
         $intOldWidth = $imageSize[0];
         $intOldHeight = $imageSize[1];
         if ($objResult->fields['size_type'] == 'abs') {
             $intNewWidth = intval($this->arrSettings['standard_width_abs']);
             $intNewHeight = intval($this->arrSettings['standard_height_abs']);
             if ($intNewWidth == 0) {
                 // exception if width and height or 0!
                 if ($intNewHeight == 0) {
                     $intNewHeight = 100;
                 }
                 $intNewWidth = round($intOldWidth * $intNewHeight / $intOldHeight, 0);
             } else {
                 if ($intNewHeight == 0) {
                     $intNewHeight = round($intOldHeight * $intNewWidth / $intOldWidth, 0);
                 }
             }
         } else {
             $intNewWidth = round($objResult->fields['size_proz'] / 100 * $intOldWidth, 0);
             $intNewHeight = round($objResult->fields['size_proz'] / 100 * $intOldHeight, 0);
         }
         //Resize the Rotated image
         if ($objImage->resizeImageSave($strOrgPath, $strWebpath, $strImagename, $intNewWidth, $intNewHeight, $objResult->fields['quality'], $strThumbPath, $strThumbWebpath, $strImagename)) {
             if ($objResult->fields['size_type'] == 'abs') {
                 $objDatabase->Execute('    UPDATE     ' . DBPREFIX . 'module_gallery_pictures
                                 SET     size_abs_h=' . $intNewHeight . ',
                                         size_abs_w=' . $intNewWidth . '
                                 WHERE     id=' . $intImageId);
             }
         }
     }
 }
開發者ID:Niggu,項目名稱:cloudrexx,代碼行數:67,代碼來源:GalleryManager.class.php


注:本文中的ImageManager::rotateImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。