本文整理匯總了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);
}