本文整理汇总了PHP中PhocaGalleryFileThumbnail::getThumbnailResize方法的典型用法代码示例。如果您正苦于以下问题:PHP PhocaGalleryFileThumbnail::getThumbnailResize方法的具体用法?PHP PhocaGalleryFileThumbnail::getThumbnailResize怎么用?PHP PhocaGalleryFileThumbnail::getThumbnailResize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhocaGalleryFileThumbnail
的用法示例。
在下文中一共展示了PhocaGalleryFileThumbnail::getThumbnailResize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rotateImage
//.........这里部分代码省略.........
$errorMsg = 'ErrorNoImageColorAllocate';
return false;
}
if (!function_exists("imagefill")) {
$errorMsg = 'ErrorNoImageFill';
return false;
}
if (!function_exists("imagecolortransparent")) {
$errorMsg = 'ErrorNoImageColorTransparent';
return false;
}
$colBlack = imagecolorallocate($image1, 0, 0, 0);
if (!function_exists("imagerotate")) {
$image2 = PhocaGalleryImageRotate::imageRotate($image1, $angle, $colBlack);
} else {
$image2 = imagerotate($image1, $angle, $colBlack);
}
imagefill($image2, 0, 0, $colBlack);
imagecolortransparent($image2, $colBlack);
break;
default:
if (!function_exists("imagerotate")) {
$image2 = PhocaGalleryImageRotate::imageRotate($image1, $angle, 0);
} else {
$image2 = imageRotate($image1, $angle, 0);
}
break;
}
// Get the image size and resize the rotated image if necessary
$rotateWidth = imagesx($image2);
// Get the size from rotated image
$rotateHeight = imagesy($image2);
// Get the size from rotated image
$parameterSize = PhocaGalleryFileThumbnail::getThumbnailResize($size);
$newWidth = $parameterSize['width'];
// Get maximum sizes, they can be displayed
$newHeight = $parameterSize['height'];
// Get maximum sizes, they can be displayed
$scale = $newWidth / $rotateWidth < $newHeight / $rotateHeight ? $newWidth / $rotateWidth : $newHeight / $rotateHeight;
// smaller rate
$src = array(0, 0, $rotateWidth, $rotateHeight);
$dst = array(0, 0, floor($rotateWidth * $scale), floor($rotateHeight * $scale));
// If original is smaller than thumbnail size, don't resize it
if ($src[2] > $dst[2] || $src[3] > $dst[3]) {
// Building image for RESIZING THE ROTATED IMAGE
$image3 = @ImageCreateTruecolor($dst[2], $dst[3]);
if (!$image3) {
$errorMsg = 'ErrorNoImageCreateTruecolor';
return false;
}
ImageCopyResampled($image3, $image2, $dst[0], $dst[1], $src[0], $src[1], $dst[2], $dst[3], $src[2], $src[3]);
switch ($type) {
case IMAGETYPE_PNG:
// imagealphablending($image2, true);
// imagesavealpha($image2, true);
if (!function_exists("imagecolorallocate")) {
$errorMsg = 'ErrorNoImageColorAllocate';
return false;
}
if (!function_exists("imagefill")) {
$errorMsg = 'ErrorNoImageFill';
return false;
}
if (!function_exists("imagecolortransparent")) {
$errorMsg = 'ErrorNoImageColorTransparent';
return false;
示例2: createFileThumbnail
function createFileThumbnail($fileOriginal, $fileThumbnail, $size, $frontUpload = 0, &$errorMsg)
{
$paramsC = JComponentHelper::getParams('com_phocagallery');
$enable_thumb_creation = $paramsC->get('enable_thumb_creation', 1);
$watermarkParams['create'] = $paramsC->get('create_watermark', 0);
// Watermark
$watermarkParams['x'] = $paramsC->get('watermark_position_x', 'center');
$watermarkParams['y'] = $paramsC->get('watermark_position_y', 'middle');
$crop_thumbnail = $paramsC->get('crop_thumbnail', 5);
// Crop or not
$crop = null;
switch ($size) {
case 'small1':
case 'small2':
case 'small3':
case 'medium1':
case 'medium2':
case 'medium3':
$crop = 1;
break;
case 'small':
if ($crop_thumbnail == 3 || $crop_thumbnail == 5 || $crop_thumbnail == 6 || $crop_thumbnail == 7) {
$crop = 1;
}
break;
case 'medium':
if ($crop_thumbnail == 2 || $crop_thumbnail == 4 || $crop_thumbnail == 5 || $crop_thumbnail == 7) {
$crop = 1;
}
break;
case 'large':
default:
if ($crop_thumbnail == 1 || $crop_thumbnail == 4 || $crop_thumbnail == 6 || $crop_thumbnail == 7) {
$crop = 1;
}
break;
}
// disable or enable the thumbnail creation
if ($enable_thumb_creation == 1) {
$fileResize = PhocaGalleryFileThumbnail::getThumbnailResize($size);
if (JFile::exists($fileOriginal)) {
//file doesn't exist, create thumbnail
if (!JFile::exists($fileThumbnail)) {
$errorMsg = 'Error4';
//Don't do thumbnail if the file is smaller (width, height) than the possible thumbnail
list($width, $height) = GetImageSize($fileOriginal);
//larger
phocagalleryimport('phocagallery.image.imagemagic');
if ($width > $fileResize['width'] || $height > $fileResize['height']) {
$imageMagic = PhocaGalleryImageMagic::imageMagic($fileOriginal, $fileThumbnail, $fileResize['width'], $fileResize['height'], $crop, null, $watermarkParams, $frontUpload, $errorMsg);
} else {
$imageMagic = PhocaGalleryImageMagic::imageMagic($fileOriginal, $fileThumbnail, $width, $height, $crop, null, $watermarkParams, $frontUpload, $errorMsg);
}
if ($imageMagic) {
return true;
} else {
return false;
// error Msg will be taken from imageMagic
}
} else {
$errorMsg = 'ThumbnailExists';
//thumbnail exists
return false;
}
} else {
$errorMsg = 'ErrorFileOriginalNotExists';
return false;
}
$errorMsg = 'Error3';
return false;
} else {
$errorMsg = 'DisabledThumbCreation';
// User have disabled the thumbanil creation e.g. because of error
return false;
}
}