本文整理汇总了PHP中Pel::setJPEGQuality方法的典型用法代码示例。如果您正苦于以下问题:PHP Pel::setJPEGQuality方法的具体用法?PHP Pel::setJPEGQuality怎么用?PHP Pel::setJPEGQuality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pel
的用法示例。
在下文中一共展示了Pel::setJPEGQuality方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resize
//.........这里部分代码省略.........
*/
if ($isOriginalSize && $params->get('use_sharpening_for_originalsize', 1) == 0) {
$im_output = $im_original;
} else {
$im_output = imagecreatetruecolor($width, $height);
$resize_faktor = $orig_height / $height;
$new_height = $height;
$new_width = $orig_width / $resize_faktor;
if ($new_width < $width) {
$resize_faktor = $orig_width / $width;
$new_width = $width;
$new_height = $orig_height / $resize_faktor;
}
imagecopyresampled($im_output, $im_original, $width / 2 - $new_width / 2, $height / 2 - $new_height / 2, 0, 0, $new_width, $new_height, $orig_width, $orig_height);
$use_sharpening = $params->get('use_sharpening', 1);
if ($use_sharpening == 1) {
// configure the sharpening
$stringSharpenMatrix = $params->get('image_sharpenMatrix', '[[-1,-1,-1],[-1,16,-1],[-1,-1,-1]]');
$sharpenMatrix = json_decode($stringSharpenMatrix);
if (null == $sharpenMatrix || count($sharpenMatrix) != 3) {
$sharpenMatrix = array(array(-1, -1, -1), array(-1, 16, -1), array(-1, -1, -1));
}
$divisor = array_sum(array_map('array_sum', $sharpenMatrix));
$offset = 0;
if (function_exists('imageconvolution')) {
if (version_compare(phpversion(), '5.5.9', '=')) {
$this->imageconvolution($im_output, $sharpenMatrix, $divisor, $offset);
} else {
imageconvolution($im_output, $sharpenMatrix, $divisor, $offset);
}
}
}
}
/**
* @var EventgalleryLibraryManagerFolder $folderMgr
* @var EventgalleryLibraryFolder $folder
*/
$folderMgr = EventgalleryLibraryManagerFolder::getInstance();
$folder = $folderMgr->getFolder($folder);
$watermark = $folder->getWatermark();
// load default watermark
if (null == $watermark || !$watermark->isPublished()) {
/**
* @var EventgalleryLibraryManagerWatermark $watermarkMgr
* @var EventgalleryLibraryWatermark $watermark
*/
$watermarkMgr = EventgalleryLibraryManagerWatermark::getInstance();
$watermark = $watermarkMgr->getDefaultWatermark();
}
if (null != $watermark && $watermark->isPublished()) {
$watermark->addWatermark($im_output);
}
$image_quality = $params->get('image_quality', 85);
if ($input_jpeg != null) {
Pel::setJPEGQuality($image_quality);
/* We want the raw JPEG data from $scaled. Luckily, one can create a
* PelJpeg object from an image resource directly: */
$output_jpeg = new PelJpeg($im_output);
/* If no Exif data was present, then $exif is null. */
if ($exif != null) {
$output_jpeg->setExif($exif);
}
/* We can now save the scaled image. */
$writeSuccess = true;
$output_jpeg->saveFile($image_thumb_file);
} else {
$writeSuccess = imagejpeg($im_output, $image_thumb_file, $image_quality);
if (!$writeSuccess) {
die("Unable to write to file {$image_thumb_file}");
}
}
if (!$writeSuccess) {
die("Unable to write to file {$image_thumb_file}");
}
$time = time() + 315360000;
touch($image_thumb_file, $time);
// add the ICC profile
try {
$o = new JPEG_ICC();
$o->LoadFromJPEG($image_file);
$o->SaveToJPEG($image_thumb_file);
} catch (Exception $e) {
}
}
$mime = ($mime = getimagesize($image_thumb_file)) ? $mime['mime'] : $mime;
$size = filesize($image_thumb_file);
$fp = fopen($image_thumb_file, "rb");
if (!($mime && $size && $fp)) {
// Error.
return;
}
if (!$debug) {
header("Content-Type: " . $mime);
header("Content-Length: " . $size);
header("Last-Modified: {$last_modified}");
}
fpassthru($fp);
die;
//$app->close();
}
示例2: copy_exif
/**
* @param $from_file
* @param $to_file
*/
function copy_exif($from_file, $to_file)
{
$size = @getimagesize($to_file);
if ($size) {
require_once dirname(__FILE__) . '/pel/autoload.php';
try {
Pel::setJPEGQuality(100);
/*
* We want the raw JPEG data from $scaled. Luckily, one can create a
* PelJpeg object from an image resource directly:
*/
$input_jpeg = new PelJpeg($from_file);
/* Retrieve the original Exif data in $jpeg (if any). */
$input_exif = $input_jpeg->getExif();
/* If no Exif data was present, then $input_exif is null. */
if ($input_exif != null) {
$input_tiff = $input_exif->getTiff();
if ($input_tiff == null) {
return;
}
$input_ifd0 = $input_tiff->getIfd();
if ($input_ifd0 == null) {
return;
}
$input_exif_ifd = $input_ifd0->getSubIfd(PelIfd::EXIF);
$input_inter_ifd = $input_ifd0->getSubIfd(PelIfd::INTEROPERABILITY);
$orientation = $input_ifd0->getEntry(PelTag::ORIENTATION);
if ($orientation != null) {
$orientation->setValue(1);
}
if (!empty($input_ifd0)) {
/*$x_resolution = $input_ifd0->getEntry( PelTag::X_RESOLUTION );
$y_resolution = $input_ifd0->getEntry( PelTag::Y_RESOLUTION );
if ( $x_resolution != null && $y_resolution != null ) {
//$x_res = $x_resolution->getValue();
//$y_res = $y_resolution->getValue();
$x_resolution->setValue( $y_res );
$y_resolution->setValue( $x_res );
}*/
$image_width = $input_ifd0->getEntry(PelTag::IMAGE_WIDTH);
$image_length = $input_ifd0->getEntry(PelTag::IMAGE_LENGTH);
if ($image_width != null && $image_length != null) {
$image_width->setValue($size[0]);
$image_length->setValue($size[1]);
}
}
if (!empty($input_exif_ifd)) {
$x_dimention = $input_exif_ifd->getEntry(PelTag::PIXEL_X_DIMENSION);
$y_dimention = $input_exif_ifd->getEntry(PelTag::PIXEL_Y_DIMENSION);
if ($x_dimention != null && $y_dimention != null) {
$x_dimention->setValue($size[0]);
$y_dimention->setValue($size[1]);
}
}
if (!empty($input_inter_ifd)) {
$rel_image_width = $input_inter_ifd->getEntry(PelTag::RELATED_IMAGE_WIDTH);
$rel_image_length = $input_inter_ifd->getEntry(PelTag::RELATED_IMAGE_LENGTH);
if ($rel_image_width != null && $rel_image_length != null) {
$rel_image_width->setValue($size[0]);
$rel_image_length->setValue($size[1]);
}
}
$output_jpeg = new PelJpeg($to_file);
$output_jpeg->setExif($input_exif);
/* We can now save the image with input_exif. */
$output_jpeg->saveFile($to_file);
}
} catch (PelException $e) {
}
}
}