本文整理汇总了PHP中PhocaGalleryImage::getJpegQuality方法的典型用法代码示例。如果您正苦于以下问题:PHP PhocaGalleryImage::getJpegQuality方法的具体用法?PHP PhocaGalleryImage::getJpegQuality怎么用?PHP PhocaGalleryImage::getJpegQuality使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhocaGalleryImage
的用法示例。
在下文中一共展示了PhocaGalleryImage::getJpegQuality方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createBgImage
public static function createBgImage($data, &$errorMsg)
{
$params = JComponentHelper::getParams('com_phocagallery');
$jfile_thumbs = $params->get('jfile_thumbs', 1);
$jpeg_quality = $params->get('jpeg_quality', 85);
$jpeg_quality = PhocaGalleryImage::getJpegQuality($jpeg_quality);
$formatIcon = 'png';
$path = PhocaGalleryPath::getPath();
$fileIn = $fileOut = $path->image_abs_front . $data['image'] . '.' . $formatIcon;
if ($fileIn !== '' && JFile::exists($fileIn)) {
$memory = 8;
$memoryLimitChanged = 0;
$memory = (int) ini_get('memory_limit');
if ($memory == 0) {
$memory = 8;
}
// Try to increase memory
if ($memory < 50) {
ini_set('memory_limit', '50M');
$memoryLimitChanged = 1;
}
$imageWidth = $data['iw'];
$imageHeight = $data['ih'];
$completeImageWidth = $imageWidth + 18;
$completeImageHeight = $imageHeight + 18;
$completeImageBackground = $data['sbgc'];
$retangleColor = $data['ibgc'];
$borderColor = $data['ibrdc'];
$shadowColor = $data['iec'];
$effect = $data['ie'];
// shadow or glow
$imgX = 6;
$imgWX = $imageWidth + 5 + $imgX;
// Image Width + space (padding) + Start Position
$imgY = 6;
$imgHY = $imageHeight + 5 + $imgY;
$brdX = $imgX - 1;
$brdWX = $imgWX + 1;
$brdY = $imgY - 1;
$brdHY = $imgHY + 1;
// Crate an image
$img = @imagecreatetruecolor($completeImageWidth, $completeImageHeight);
if (!$img) {
$errorMsg = 'ErrorNoImageCreateTruecolor';
return false;
}
if ($completeImageBackground == '') {
switch ($formatIcon) {
case 'jpg':
case 'jpeg':
case 'gif':
$completeImageBackground = '#ffffff';
break;
case 'png':
@imagealphablending($img, false);
imagefilledrectangle($img, 0, 0, $completeImageWidth, $completeImageHeight, imagecolorallocatealpha($img, 255, 255, 255, 127));
@imagealphablending($img, true);
break;
}
} else {
$bGClr = PhocaGalleryUtils::htmlToRgb($completeImageBackground);
imagefilledrectangle($img, 0, 0, $completeImageWidth, $completeImageHeight, imagecolorallocate($img, $bGClr[0], $bGClr[1], $bGClr[2]));
}
// Create Retangle
if ($retangleColor != '') {
$rtgClr = PhocaGalleryUtils::htmlToRgb($retangleColor);
$retangle = imagecolorallocate($img, $rtgClr[0], $rtgClr[1], $rtgClr[2]);
}
// Create Border
if ($borderColor != '') {
$brdClr = PhocaGalleryUtils::htmlToRgb($borderColor);
$border = imagecolorallocate($img, $brdClr[0], $brdClr[1], $brdClr[2]);
}
// Effect (shadow,glow)
if ((int) $effect > 0) {
if ($shadowColor != '') {
$shdClr = PhocaGalleryUtils::htmlToRgb($shadowColor);
if ((int) $effect == 3) {
$shdX = $brdX - 1;
$shdY = $brdY - 1;
$effectArray = array(55, 70, 85, 100, 115);
} else {
if ((int) $effect == 2) {
$shdX = $brdX + 3;
$shdY = $brdY + 3;
$effectArray = array(50, 70, 90, 110);
} else {
$shdX = $brdX + 3;
$shdY = $brdY + 3;
$effectArray = array(0, 0, 0, 0);
}
}
$shdWX = $brdWX + 1;
$shdHY = $brdHY + 1;
foreach ($effectArray as $key => $value) {
$effectImg = @imagecolorallocatealpha($img, $shdClr[0], $shdClr[1], $shdClr[2], $value);
if (!$effectImg) {
$errorMsg = 'ErrorNoImageColorAllocateAlpha';
return false;
}
//.........这里部分代码省略.........
示例2: rotateImage
public static function rotateImage($thumbName, $size, $angle = 90, &$errorMsg)
{
$params = JComponentHelper::getParams('com_phocagallery');
$jfile_thumbs = $params->get('jfile_thumbs', 1);
$jpeg_quality = $params->get('jpeg_quality', 85);
$jpeg_quality = PhocaGalleryImage::getJpegQuality($jpeg_quality);
// Try to change the size
$memory = 8;
$memoryLimitChanged = 0;
$memory = (int) ini_get('memory_limit');
if ($memory == 0) {
$memory = 8;
}
$fileIn = $thumbName->abs;
$fileOut = $thumbName->abs;
if ($fileIn !== '' && file_exists($fileIn)) {
//array of width, height, IMAGETYPE, "height=x width=x" (string)
list($w, $h, $type) = GetImageSize($fileIn);
// we got the info from GetImageSize
if ($w > 0 && $h > 0 && $type != '') {
// Change the $w against $h because of rotating
$src = array(0, 0, $w, $h);
$dst = array(0, 0, $h, $w);
} else {
$errorMsg = 'ErrorWorHorType';
return false;
}
// Try to increase memory
if ($memory < 50) {
ini_set('memory_limit', '50M');
$memoryLimitChanged = 1;
}
switch ($type) {
case IMAGETYPE_JPEG:
if (!function_exists('ImageCreateFromJPEG')) {
$errorMsg = 'ErrorNoJPGFunction';
return false;
}
//$image1 = ImageCreateFromJPEG($fileIn);
try {
$image1 = ImageCreateFromJPEG($fileIn);
} catch (\Exception $exception) {
$errorMsg = 'ErrorJPGFunction';
return false;
}
break;
case IMAGETYPE_PNG:
if (!function_exists('ImageCreateFromPNG')) {
$errorMsg = 'ErrorNoPNGFunction';
return false;
}
//$image1 = ImageCreateFromPNG($fileIn);
try {
$image1 = ImageCreateFromPNG($fileIn);
} catch (\Exception $exception) {
$errorMsg = 'ErrorPNGFunction';
return false;
}
break;
case IMAGETYPE_GIF:
if (!function_exists('ImageCreateFromGIF')) {
$errorMsg = 'ErrorNoGIFFunction';
return false;
}
//$image1 = ImageCreateFromGIF($fileIn);
try {
$image1 = ImageCreateFromGIF($fileIn);
} catch (\Exception $exception) {
$errorMsg = 'ErrorGIFFunction';
return false;
}
break;
case IMAGETYPE_WBMP:
if (!function_exists('ImageCreateFromWBMP')) {
$errorMsg = 'ErrorNoWBMPFunction';
return false;
}
//$image1 = ImageCreateFromWBMP($fileIn);
try {
$image1 = ImageCreateFromWBMP($fileIn);
} catch (\Exception $exception) {
$errorMsg = 'ErrorWBMPFunction';
return false;
}
break;
default:
$errorMsg = 'ErrorNotSupportedImage';
return false;
break;
}
if ($image1) {
// Building image for ROTATING
/* $image2 = @ImageCreateTruecolor($dst[2], $dst[3]);
if (!$image2) {
return 'ErrorNoImageCreateTruecolor';
}*/
/* if(!function_exists("imagerotate")) {
$errorMsg = 'ErrorNoImageRotate';
return false;
}*/
//.........这里部分代码省略.........
示例3: imageMagic
/**
* need GD library (first PHP line WIN: dl("php_gd.dll"); UNIX: dl("gd.so");
* www.boutell.com/gd/
* interval.cz/clanky/php-skript-pro-generovani-galerie-obrazku-2/
* cz.php.net/imagecopyresampled
* www.linuxsoft.cz/sw_detail.php?id_item=871
* www.webtip.cz/art/wt_tech_php/liquid_ir.html
* php.vrana.cz/zmensovani-obrazku.php
* diskuse.jakpsatweb.cz/
*
* @param string $fileIn Vstupni soubor (mel by existovat)
* @param string $fileOut Vystupni soubor, null ho jenom zobrazi (taky kdyz nema pravo se zapsat :)
* @param int $width Vysledna sirka (maximalni)
* @param int $height Vysledna vyska (maximalni)
* @param bool $crop Orez (true, obrazek bude presne tak velky), jinak jenom Resample (udane maximalni rozmery)
* @param int $typeOut IMAGETYPE_type vystupniho obrazku
* @return bool Chyba kdyz vrati false
*/
public static function imageMagic($fileIn, $fileOut = null, $width = null, $height = null, $crop = null, $typeOut = null, $watermarkParams = array(), $frontUpload = 0, &$errorMsg)
{
$params = JComponentHelper::getParams('com_phocagallery');
$jfile_thumbs = $params->get('jfile_thumbs', 1);
$jpeg_quality = $params->get('jpeg_quality', 85);
$jpeg_quality = PhocaGalleryImage::getJpegQuality($jpeg_quality);
$fileWatermark = '';
// While front upload we don't display the process page
if ($frontUpload == 0) {
$stopText = PhocaGalleryRenderProcess::displayStopThumbnailsCreating('processpage');
echo $stopText;
}
// Memory - - - - - - - -
$memory = 8;
$memoryLimitChanged = 0;
$memory = (int) ini_get('memory_limit');
if ($memory == 0) {
$memory = 8;
}
// - - - - - - - - - - -
if ($fileIn !== '' && JFile::exists($fileIn)) {
// array of width, height, IMAGETYPE, "height=x width=x" (string)
list($w, $h, $type) = GetImageSize($fileIn);
if ($w > 0 && $h > 0) {
// we got the info from GetImageSize
// size of the image
if ($width == null || $width == 0) {
// no width added
$width = $w;
} else {
if ($height == null || $height == 0) {
// no height, adding the same as width
$height = $width;
}
}
if ($height == null || $height == 0) {
// no height, no width
$height = $h;
}
// miniaturizing
if (!$crop) {
// new size - nw, nh (new width/height)
$scale = $width / $w < $height / $h ? $width / $w : $height / $h;
// smaller rate
$src = array(0, 0, $w, $h);
$dst = array(0, 0, floor($w * $scale), floor($h * $scale));
} else {
// will be cropped
$scale = $width / $w > $height / $h ? $width / $w : $height / $h;
// greater rate
$newW = $width / $scale;
// check the size of in file
$newH = $height / $scale;
// which side is larger (rounding error)
if ($w - $newW > $h - $newH) {
$src = array(floor(($w - $newW) / 2), 0, floor($newW), $h);
} else {
$src = array(0, floor(($h - $newH) / 2), $w, floor($newH));
}
$dst = array(0, 0, floor($width), floor($height));
}
// Watermark - - - - - - - - - - -
if (!empty($watermarkParams) && ($watermarkParams['create'] == 1 || $watermarkParams['create'] == 2)) {
$thumbnailSmall = false;
$thumbnailMedium = false;
$thumbnailLarge = false;
$thumbnailMedium = preg_match("/phoca_thumb_m_/i", $fileOut);
$thumbnailLarge = preg_match("/phoca_thumb_l_/i", $fileOut);
$path = PhocaGalleryPath::getPath();
$fileName = PhocaGalleryFile::getTitleFromFile($fileIn, 1);
// Which Watermark will be used
// If watermark is in current directory use it else use Default
$fileWatermarkMedium = str_replace($fileName, 'watermark-medium.png', $fileIn);
$fileWatermarkLarge = str_replace($fileName, 'watermark-large.png', $fileIn);
clearstatcache();
// Which Watermark will be used
if ($thumbnailMedium) {
if (JFile::exists($fileWatermarkMedium)) {
$fileWatermark = $fileWatermarkMedium;
} else {
if ($watermarkParams['create'] == 2) {
$fileWatermark = $path->image_abs . 'watermark-medium.png';
//.........这里部分代码省略.........