/** * Creates a thumbnail of a picture * * Note that all "Path" parameters are required to bring along their * own trailing slash. * * @param string $strPath * @param string $strWebPath * @param string $file * @param int $maxSize The maximum width or height of the image * @param int $quality * @return boolean */ function _createThumb($strPath, $strWebPath, $file, $maxSize = 80, $quality = 90, $thumb_name = '', $generateThumbnailByRatio = false) { $_objImage = new ImageManager(); $file = basename($file); $tmpSize = getimagesize($strPath . $file); $factor = 1; if ($tmpSize[0] > $tmpSize[1]) { $factor = $maxSize / $tmpSize[0]; } else { $factor = $maxSize / $tmpSize[1]; } $thumbWidth = $tmpSize[0] * $factor; $thumbHeight = $tmpSize[1] * $factor; if (!$_objImage->loadImage($strPath . $file)) { return false; } if ($generateThumbnailByRatio && !$_objImage->resizeImageWithAspectRatio($thumbWidth, $thumbHeight, $quality)) { return false; } elseif (!$generateThumbnailByRatio && !$_objImage->resizeImage($thumbWidth, $thumbHeight, $quality)) { return false; } if (!(strlen($thumb_name) > 0)) { $thumb_name = self::getThumbnailFilename($file); } if (!$_objImage->saveNewImage($strPath . $thumb_name)) { return false; } if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($strPath . $thumb_name)) { return false; } return true; }