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;
?>
Imagick::setImageFormat
(No version information available, might be only in CVS)
Imagick::setImageFormat — 特定の画像のフォーマットを設定する
説明
bool Imagick::setImageFormat
( string $format
)
警告
この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。
シーケンス内の特定の画像のフォーマットを設定します。
パラメータ
- format
-
画像フォーマットを表す文字列。対応するフォーマットは、 インストールされている ImageMagick に依存します。
返り値
成功した場合に TRUE を返します。
Imagick::setImageFormat
barclay[dot]loftus[at]gmail.com
13-Mar-2008 01:04
13-Mar-2008 01:04
optymizer at yahoo dot com
22-Nov-2007 01:09
22-Nov-2007 01: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)
{
$image->readImage($filename);
$image->setImageFormat("png");
header("Content-type: image/png");
echo $image->getImageBlob();
}
Hope this helps!
Devo
08-Oct-2007 06:02
08-Oct-2007 06:02
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" );
?>
