PHP Doku:: Sets the object s default compression quality - function.imagick-setcompressionquality.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzBildverarbeitung und -generierungImage Processing (ImageMagick)The Imagick classImagick::setCompressionQuality

Ein Service von Reinhard Neidl - Webprogrammierung.

The Imagick class




(PECL imagick 0.9.10-0.9.9)

Imagick::setCompressionQualitySets the object's default compression quality


bool Imagick::setCompressionQuality ( int $quality )

Diese Funktion ist bis jetzt nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfügung.

Sets the object's default compression quality.




Liefert TRUE bei Erfolg.

4 BenutzerBeiträge:
- Beiträge aktualisieren...
charles dot hall at sas dot com
3.08.2010 20:31
I had to insert a call to "stripImage()" in order to actually see the filesize shrink.

= new Imagick();
deeps chennai
18.03.2010 11:59
A note for people who just couldn't get this working..

With PHP 5.1.6, the below works:


However, with higher versions of PHP (I tried on PHP 5.2.10), the code has no effect (and there are no exceptions or warnings thrown by Imagick as well).

The code that works instead is:


and this is backwards compatible (Works on PHP 5.1.6 as well as 5.2.10)
27.03.2008 5:24
Sebastian's example works excellent, just one minor spelling mistake, it will give you an error otherwise.


I used Sebastians example, and made one that compresses all the images within a directory:

= new Imagick(glob('images/*.jpg'));

$images as $image)
// compression methods, see "Contants"-page for Imagick
// a value between 1 and 100, 1 = high compression, 100 low compression

sebastian dot moser at gmail dot com
17.11.2007 11:46
Use this example to see how image compression works:

// load an image
$img = new Imagick("test.jpg");

// compression methods, see "Contants"-page for Imagick
// a value between 1 and 100, 1 = high compression, 100 low compression

// set content type
header("Content-type: image/jpeg");
// write image
echo $img->getImageBlob();

PHP Powered Diese Seite bei
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)