Page 1 of 1
Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-19T11:21:20-07:00
by peterb
Hello,
I'm experiencing a curious issue when using convert to flatten a photoshop file containing 2 alpha channels into a JPG. The two channels are, for lack of better names, the "primary" (the intrinsic channel produced when on removes the background in photoshop), and a "user defined" channel (created when a user explicitly creates a new channel in photoshop). Despite this user defined channel being hidden, the two are still being oddly combined on flatten, producing a strange artifact. Illustrative blurry blobs bellow:
Image with intrinsic alpha:
Hidden user alpha:
Image flattened using photoshop:
Image flattened to jpg using convert -flatten (ImageMagick 6.5.4-10)
The PSD in question is
here.
Is this a bug, or am I just misusing convert? If I could find a way to detect and strip that user defined channel, guess that would be a workaround, but I am unsure how to go about doing that. Any help would be much appreciated.
Thanks.
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-19T11:47:42-07:00
by magick
Try this command:
- convert 'redblackthing.psd[1]' redblackthing.png
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-19T13:28:11-07:00
by peterb
Thanks for the speedy reply,
magick wrote:Try this command:
- convert 'redblackthing.psd[1]' redblackthing.png
This sort of works ... it does produce a clean image BUT also clips the completely transparent edges of the image, changing its size and requiring some extra steps to reconstruct the dimensions and positioning of the original. I know, I know, beggars can't be choosers.
Also, how did you know to use layer/frame 1?
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-19T15:26:53-07:00
by fmw42
try this
convert redblackthing.psd[0] -background white -flatten -quality 100 redblackthing.jpg
The first (zero) frame of the psd generally contains the composite of all the other channels.
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-19T15:49:11-07:00
by peterb
fmw42 wrote:
convert redblackthing.psd[0] -background white -flatten -quality 100 redblackthing.jpg
The first (zero) frame of the psd generally contains the composite of all the other channels.
Sadly fmw42, no dice:
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-19T17:05:42-07:00
by anthony
Reading PSD images is tricky, The file format usually starts with a 'pre-flattened' image as the first (zeroth) image, followed by the other images. It looks like that the hidden alpha image is then stored as a the second image simply as a mask.
Can you get use the number of images IM reads from the PSD, and a copy of what each image is? Also what is it you desire to do with the 'hidden alpha' image?
Junk it? Replace the current alpha? Merge with the current alpha? What?
What do you want?
You haven't actually told us, so everyone is just sort of guessing!
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-19T18:13:56-07:00
by fmw42
fmw42 wrote:try this
convert redblackthing.psd[0] -background white -flatten -quality 100 redblackthing.jpg
The first (zero) frame of the psd generally contains the composite of all the other channels.
Strange as this is what I get (IM 6.5.4-10 Q16 HDRI Mac OSX Tiger):
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-20T09:01:18-07:00
by peterb
anthony wrote:The file format usually starts with a 'pre-flattened' image as the first (zeroth) image, followed by the other images. It looks like that the hidden alpha image is then stored as a the second image simply as a mask.
Can you get use the number of images IM reads from the PSD, and a copy of what each image is?
If I'm interpreting convert correctly only 2 images are detected (ie, it only addresses redblackthing.psd[0] and redblackthing.psd[1]). Looks like you, anthony (and fmw42) are correct, the first image (redblackthing.psd[0]) is indeed 'pre-flattened' and a direct conversion produces exactly what I want!
convert redblackthing.psd[0] -quality 100 redblackthing.jpg
Oddly, its only when I add an explicit -flatten to the first image that things go awry ... though, maddeningly, only for me (fmw42 - I got
that result twice using a slightly older build (IM 6.5.1-0 2009-04-20 Q16) on linux and the latest binary (IM 6.5.4-10 Q16) on windows ... maybe we have different configs?).
anthony wrote:
Also what is it you desire to do with the 'hidden alpha' image?
Junk it? Replace the current alpha? Merge with the current alpha? What?
What do you want?
You haven't actually told us, so everyone is just sort of guessing!
I apologize if I wasn't completely clear - I just want convert -flatten to work as expected, producing the same results flattening a simple psd as one would get from photoshop. I don't care what happens to the hidden alpha, I just want it to stay hidden during the the flattening process, which is not currently happening.
Now, if my expectations are wrong, and I should just always be using the first (zero) image of a psd instead of -flatten, that's a different matter...
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-20T10:05:50-07:00
by fmw42
suspect you need to upgrade to 6.5.4-10 as there may be bugs or differences in older versions of IM
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-20T13:35:11-07:00
by peterb
fmw42 wrote:suspect you need to upgrade to 6.5.4-10 as there may be bugs or differences in older versions of IM
A reasonable concern, which is why I sanity checked with the latest (6.5.4-10) binary on windows and still got the same result. So strange. Looks like extracting (but not flattening!) the first (zero) image is my solution for now.
Still, this is a much better solution than I had before. Thanks for the help everyone.
Re: Issue Flattening PSD to JPG with multiple alpha channels
Posted: 2009-08-20T15:31:24-07:00
by fmw42
certainly does not explain why this works for me on IM 6.5.4.-10 Q16 (HDRI) and I don't think it has anything to do with the HDRI
convert redblackthing.psd[0] -background white -flatten -quality 100 redblackthing.jpg
perhaps it is your libjpeg?
(I am using libjpeg-6b.tar.gz)