PHP Doku:: Sets the format of a particular image - function.imagick-setimageformat.html

Verlauf / Chronik / History: (1) anzeigen

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

Ein Service von Reinhard Neidl - Webprogrammierung.

The Imagick class




(PECL imagick 2.0.0)

Imagick::setImageFormatSets the format of a particular image


bool Imagick::setImageFormat ( string $format )

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

Sets the format of a particular image in a sequence.



String presentation of the image format. Format support depends on the ImageMagick installation.


Liefert TRUE bei Erfolg.

5 BenutzerBeiträge:
- Beiträge aktualisieren...
nathan at crause dot name
18.08.2010 18:35
For those of you completely confused by the utter lack of documentation for this class (including notes being dropped, probably this one included), the differences between any "setXXX" and "setImageXXX" seems to be entirely dependently on HOW the image was loaded.

If the image was loaded at object constructor time, it seems that you use "setXXX" - if you loaded it after the fact (such as via "readImageBlob") then you use "setImageXXX".

This is irregular, however. For example:

= new Imagick();

$image->setResolution(300, 300);
// convert the output to JPEG

Note that we use "setResolution" not "setImageResolution".
andy at live dot nl
26.02.2009 15:54
I had a problem when using $im->setImageFormat('jpeg');
Image colors got inverted when i converted pdfs to jpg thumbs.
Had to add $im->setImageColorspace(255); to solve it.

// read page 1
$im = new imagick( 'test.pdf[ 0]' );

// convert to jpg

$im->resizeImage(290, 375, imagick::FILTER_LANCZOS, 1); 

//write image on server
13.03.2008 0:04
Another note about image output. For jpeg images, the quality is adjusted by Imagick::setCompressionQuality().

header('Content-type: image/jpg');
optymizer at yahoo dot com
22.11.2007 0:09
The previous example did not work for me. I received an error that the IMagick object cannot be converted to string.

This example uses the IMagick::getImageBlob() method to properly output the contents of the converted image:

function getImage($filename)
            header("Content-type: image/png");
            echo $image->getImageBlob();

Hope this helps!
8.10.2007 5:02
A list of formats can be found here:

Formats marked with a W can be output to file with writeImage (capabilities depend on your particular installation of course).

For example:

// create new imagick object from image.jpg
$im = new Imagick( "image.jpg" );

// change format to png
$im->setImageFormat( "png" );

// output the image to the browser as a png
header( "Content-Type: image/png" );

// or you could output the image to a file:
//$im->writeImage( "image.png" );

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",...)