After seeing feature rich options in Imagick PECL extension at Mikko Koppanen's (the author) website and also impressed with ImageMagick's features, I have decided to use it for the PSD to XHTML conversion website that I'm architecting and managing.
Since, the team wants programming help for converting PSD images, I have tried it (documentation is sparse on PSD handling)
Note that,
Note that, there is a better version below
In a single call with
Note: Second parameter of
While doing so and comparing with the results of XnView, I have noted a same problem/issue as mentioned here in the forum--that is, most of the extracted layers/images are distorted. By the way, I have tried in WAMP and yet to try it in LAMP
Since, the team wants programming help for converting PSD images, I have tried it (documentation is sparse on PSD handling)
Converting PSD to PNG/JPEG/etc
Note that,
flattenImages()
is needed for layered/multi-page PSD file.
<?php
$im = new Imagick('test.psd');
$im->flattenImages();
$im->setImageFormat('png');
$im->writeImage('test.png');
?>
Extracting PSD layers
One by one
<?php
$im = new Imagick('test.psd');
$im->setImageFormat('png');
for ($i = 0, $num_layers = $im->getNumberImages(); $i < $num_layers; ++$i) {
$im->setImageIndex($i);
$im->writeImage('layer' . $i . '.png');
}
?>
Note that, there is a better version below
In a single call with writeImages()
<?php
$im = new Imagick('test.psd');
$im->setImageFormat('png');
$im->writeImages('layer%d.png', true);
?>
Note: Second parameter of
writeImages()
is for adjoinBug
While doing so and comparing with the results of XnView, I have noted a same problem/issue as mentioned here in the forum--that is, most of the extracted layers/images are distorted. By the way, I have tried in WAMP and yet to try it in LAMP
Comments
After second thought, you'd be better off with the command line "convert" instead of this extension