Converting PSDs to PNG with layer names intact

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Figbash

Converting PSDs to PNG with layer names intact

Post by Figbash » 2010-04-22T11:02:53-07:00

Hello, I'm new to imagemagick and have been poring over the docs to figure this out, but I give up :)

I'm trying to take a source PSD file and export all of it's layers into PNG files, which are titled with the name of the layer. I'm unsure if IM can get Group information from PSDs, but if it can I would also like to have that in the title of the PNG.

So a list of "GroupName-LayerName.PNG" files would be the result.

I see the layername listed as label: in the output from identify verbose, but I'm unsure how to use this in Convert? Anyone know how to do this?

User avatar
fmw42
Posts: 21120
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Converting PSDs to PNG with layer names intact

Post by fmw42 » 2010-04-22T12:00:00-07:00

if it is in the verbose info, then you will likely need to write a script to get the name first and put into a variable, then use convert to extract the layer you want and give the output name according to the variable value you had extracted. You will need to loop over each layer in the image.

can you post a link to a sample pdf with the layer names in the verbose info?

Figbash

Re: Converting PSDs to PNG with layer names intact

Post by Figbash » 2010-04-22T14:17:08-07:00

Here's a file with two layers in it

http://flyingworm.com/TestLayers.psd

User avatar
fmw42
Posts: 21120
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Converting PSDs to PNG with layer names intact

Post by fmw42 » 2010-04-22T15:18:23-07:00

here is how to get the name of the label from a given frame

label=`convert TestLayers.psd[1] -verbose info: | grep "label:" | cut -d: -f 2 | cut -d\ -f2`
echo $label
TestLayer

you just need to find out how many layers

numlayer=`convert TestLayers.psd -format "%[scenes]" info: | head -n 1`
echo $numlayers
3

Then loop through each layer in a script and get the label name and use that in your convert

convert TestLayers.psd[1] TestLayers-${label}.png

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 15 guests