本文整理汇总了PHP中imagick::stripImage方法的典型用法代码示例。如果您正苦于以下问题:PHP imagick::stripImage方法的具体用法?PHP imagick::stripImage怎么用?PHP imagick::stripImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagick
的用法示例。
在下文中一共展示了imagick::stripImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resize_imagick
private function resize_imagick($src, $width, $height, $quality, $preserveExif)
{
try {
$img = new imagick($src);
if (strtoupper($img->getImageFormat()) === 'JPEG') {
$img->setImageCompression(imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality($quality);
if (!$preserveExif) {
try {
$orientation = $img->getImageOrientation();
} catch (ImagickException $e) {
$orientation = 0;
}
$img->stripImage();
if ($orientation) {
$img->setImageOrientation($orientation);
}
}
}
$img->resizeImage($width, $height, Imagick::FILTER_LANCZOS, true);
$result = $img->writeImage($src);
$img->clear();
$img->destroy();
return $result ? true : false;
} catch (Exception $e) {
return false;
}
}
示例2: resize
public static function resize($orig_file_path, $settings, $target_file_path)
{
$quality = 95;
$crop = $settings['crop_method'];
$current_width = $settings['width'];
$current_height = $settings['height'];
$target_width = min($current_width, $settings['width_requested']);
$target_height = min($current_height, $settings['height_requested']);
if ($crop) {
$x_ratio = $target_width / $current_width;
$y_ratio = $target_height / $current_height;
$ratio = min($x_ratio, $y_ratio);
$use_x_ratio = $x_ratio == $ratio;
$new_width = $use_x_ratio ? $target_width : floor($current_width * $ratio);
$new_height = !$use_x_ratio ? $target_height : floor($current_height * $ratio);
} else {
$new_width = $target_width;
$new_height = $target_height;
}
$im = new imagick($orig_file_path);
$im->cropThumbnailImage($new_width, $new_height);
$im->setImageCompression(imagick::COMPRESSION_JPEG);
$im->setImageCompressionQuality($quality);
$im->stripImage();
$result = $im->writeImage($target_file_path);
$im->destroy();
return array($new_width, $new_height, $target_width, $target_height);
}