Convert Photoshop PSD File With Imagick

Convert Photoshop PSD File With Imagick

The PHP Imagick extension is so amazingly amazing, that it can read Photoshop .psd files. This means that once they are read into the imagick object, all the functions available to the imagick extension, through imagemagick, are able to used on the image.

This enables the coder to convert, thumbnail, add effects, rotate or any other manipulation you can think of. In the example below, the my.psd file is read into imagick and a thumbnail is created, before outputting the image as a portable network graphic (PNG) file.


/*** the image name ***/
$image 'my.psd';

/*** read the image into imagick ***/
$im = new Imagick$image );

/*** convert to png ***/

/*** thumbnail the image ***/
$im->thumbnailImage200null );

/*** set the correct header ***/
header"Content-Type: image/png" );

/*** display the image ***/
echo $im;