Imagick::setImageFormat

(PECL imagick 2.0.0)

Imagick::setImageFormatSets the format of a particular image

Описание

bool Imagick::setImageFormat ( string $format )
Внимание

К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.

Sets the format of a particular image in a sequence.

Список параметров

format

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

Возвращаемые значения

В случае успешной работы возвращает TRUE.

Коментарии

Автор:
A list of formats can be found here: http://www.imagemagick.org/script/formats.php

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

For example:

<?php
// 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" );
echo 
$im;

// or you could output the image to a file:
//$im->writeImage( "image.png" );
?>
2007-10-08 06:02:57
http://php5.kiev.ua/manual/ru/function.imagick-setimageformat.html
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)
{
            $image->readImage($filename);
            $image->setImageFormat("png");
            header("Content-type: image/png");
            echo $image->getImageBlob();
}

Hope this helps!
2007-11-22 01:09:41
http://php5.kiev.ua/manual/ru/function.imagick-setimageformat.html
Another note about image output. For jpeg images, the quality is adjusted by Imagick::setCompressionQuality(). 

<?php
$img
->setCompressionQuality(90);
$img->setImageFormat('jpeg');
header('Content-type: image/jpg');
echo 
$img;
?>
2008-03-13 01:04:52
http://php5.kiev.ua/manual/ru/function.imagick-setimageformat.html
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.

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

// convert to jpg
$im->setImageColorspace(255);
$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(60);
$im->setImageFormat('jpeg');

//resize
$im->resizeImage(290375imagick::FILTER_LANCZOS1); 

//write image on server
$im->writeImage('thumb.jpg');
$im->clear();
$im->destroy();
?>
2009-02-26 16:54:53
http://php5.kiev.ua/manual/ru/function.imagick-setimageformat.html
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:

<?php
        $image 
= new Imagick();

       
$image->setResolution(300300);
       
$image->readImageBlob(...);
       
// convert the output to JPEG
       
$image->setImageFormat('jpeg');
       
$image->setImageCompressionQuality(90);
?>

Note that we use "setResolution" not "setImageResolution".
2010-08-18 19:35:07
http://php5.kiev.ua/manual/ru/function.imagick-setimageformat.html

    Поддержать сайт на родительском проекте КГБ