/** * 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); } } } }