Page 1 of 1

Keep/discard alfa depending on opacity

Posted: 2018-04-17T08:32:51-07:00
by elmimmo
I want to batch convert multiple PSD to a TIFF files without layers. If I am not mistaken, I can just grab the composite version of the PSD by appending [0] to its filename, but then, regarding the alpha, is there a way to programmatically keep it or discard it depending on whether there actually exists any non-opaque pixel in the image at all or discard it if not? Even better, could that test ignore the outmost n-pixels in the four edges of the image?

Re: Keep/discard alfa depending on opacity

Posted: 2018-04-17T08:42:05-07:00
by elmimmo
I found that I can query if the composite PSD "is image fully-opaque?" with

Code: Select all

identify -format %[opaque] ${PSD}[0]

Re: Keep/discard alfa depending on opacity

Posted: 2018-04-17T08:43:23-07:00
by snibgo
Yes. I would do it in a script. Convert it, and test for %[opaque] in the result. If "True" then convert again with "-alpha off".

If you want to ignore some pixels for the test, then crop or shave the image.