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

search for in the

Imagick::setImageGamma> <Imagick::setImageFilename
Last updated: Fri, 20 Nov 2009

view this page in

Imagick::setImageFormat

(PECL imagick 2.0.0)

Imagick::setImageFormatSets the format of a particular image

Description

bool Imagick::setImageFormat ( string $format )
Warning

This function is currently not documented; only its argument list is available.

Sets the format of a particular image in a sequence.

Parameters

format

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

Return Values

Returns TRUE on success.



Imagick::setImageGamma> <Imagick::setImageFilename
Last updated: Fri, 20 Nov 2009
 
add a note add a note User Contributed Notes
Imagick::setImageFormat
andy at live dot nl
26-Feb-2009 02: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.

<?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(290, 375, imagick::FILTER_LANCZOS, 1); 

//write image on server
$im->writeImage('thumb.jpg');
$im->clear();
$im->destroy();
?>
barclay[dot]loftus[at]gmail.com
12-Mar-2008 11:04
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;
?>
optymizer at yahoo dot com
21-Nov-2007 11: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 03: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" );
?>

Imagick::setImageGamma> <Imagick::setImageFilename
Last updated: Fri, 20 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites