Page 1 of 1

PSD layers to PNG, trimming based on opacity of composite image including hidden layers

Posted: 2016-03-17T10:22:27-07:00
by elmimmo
I want to export PSD layers to PNG, maintaining the layers' layout (i.e. keeping transparent areas in each one so that stacking them back still produces the original illustration), but still trimming out areas that would be transparent in their composite version including layers which are hidden in the original PSD.

The following command

Code: Select all

convert IN.PSD OUT.PNG
extracts all layers keeping their layout but

• the composite image of all visible layers is created too, with suffix 0, which I do not need nor want.
• each layer trims areas that are transparent only on itself. I want to trim transparent areas common to all layers, visible and invisible.

This other command

Code: Select all

convert IN.PSD -set dispose Background -coalesce OUT.PNG
accomplishes the same but trims nothing at all.

Re: PSD layers to PNG, trimming based on opacity of composite image including hidden layers

Posted: 2016-03-17T10:33:53-07:00
by snibgo
I'm not sure, but the following might extract all layers except number 0:

Code: Select all

convert IN.PSD[1--1] OUT.PNG
"1--1" means start at number 1, and stop at the last one.

If this gives all the layers, including "invisible" layers, you can "-layers merge" them, and "-format %@" will tell you what the trim boundaries of that image would be. You can then trim all the layers with that crop specification.