How can I read psd file using php

Dipesh Parmar picture Dipesh Parmar · Jul 2, 2013 · Viewed 7.7k times · Source

I need to read PSD file into PHP code and get group layers and X-Y positions.

How can i do it? I've heard of ImageMagick but never worked on it.

If you guys have some links to get started please provide it to me.

Answer

Frxstrem picture Frxstrem · Jul 2, 2013

You can use ImageMagick for this, using something like:

$im = new Imagick("image.psd");

foreach($im as $layer) {
  // do something with each $layer

  // example: save all layers to separate PNG files
  $layer->writeImage("layer" . ++$i . ".png");
}

Also, you can look at this answer to a question similar to yours, and has some code examples for how to get x,y positions of layers, for instance.