7

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.

Wesley Murch
  • 98,378
  • 36
  • 187
  • 224
Dipesh Parmar
  • 26,601
  • 7
  • 57
  • 86
  • Not sure if this helps: http://www.phpclasses.org/package/3627-PHP-Open-images-in-the-PhotoShop-PSD-format.html – karmafunk Jul 02 '13 at 13:14
  • @karmafunk many thanks for response but that was the first thing i have tried but its converting into image but i want to read payers.. – Dipesh Parmar Jul 02 '13 at 13:17
  • 1
    In case nothing exists, you can do it yourself by parsing the file: http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ – roptch Jul 02 '13 at 13:19

1 Answers1

7

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.

Community
  • 1
  • 1
Frxstrem
  • 34,562
  • 9
  • 73
  • 106