downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Imagick::setImageDelay> <Imagick::setImageCompression
[edit] Last updated: Fri, 25 May 2012

view this page in

Imagick::setImageCompressionQuality

(バージョン情報なし。おそらく SVN 版にしか存在しないでしょう)

Imagick::setImageCompressionQuality画像の圧縮品質を設定する

説明

bool Imagick::setImageCompressionQuality ( int $quality )

画像の圧縮品質を設定します。

パラメータ

quality

画像の圧縮品質を表す整数値。

返り値

成功した場合に TRUE を返します。

エラー / 例外

エラー時に ImagickException をスローします。



add a note add a note User Contributed Notes Imagick::setImageCompressionQuality
snipes2083 [at] yahoo com 28-Mar-2010 05:35
This example shows how to set the compression type, set the compression quality, create a thumbnail and remove unnecessary data in order to reduce file size.

This will use the following functions in reference:
Imagick::setImageCompression
Imagick::setImageCompressionQuality
Imagick::stripImage
Imagick::thumbnailImage
Imagick::writeImage

<?php
    $image
= 'image.jpg';
   
$directory = '/path/to/image';
   
$image_location = $directory . "/" . $image;
   
$thumb_destination = $directory . "/t" . $image;
   
$compression_type = Imagick::COMPRESSION_JPEG;
  
   
$im = new Imagick($image_location);
   
$thumbnail = $im->clone;

   
$thumbnail->setImageCompression($compression_type);
   
$thumbnail->setImageCompressionQuality(40);
   
$thumbnail->stripImage();
   
$thumbnail->thumbnailImage(100,null);
   
$thumbnail->writeImage($thumb_destination);
?>

Now, obviously you don't have to do so much with the variables and the file location.  I only used so many to demonstrate where the images are coming from and where they are going.

NOTE:  The $thumbnail->thumbnailImage(100,null); keeps the aspect ration by setting the second parameter to null.  Read about this at Imagick::thumbnailImage

There is another way to create thumbnails that works quite well if you want to crop the image rather than using the entire image.  Check out Imagick::cropThumbnailImage

 
show source | credits | stats | sitemap | contact | advertising | mirror sites