Issue Flattening PSD to JPG with multiple alpha channels
Issue Flattening PSD to JPG with multiple alpha channels
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.
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
Try this command:
- convert 'redblackthing.psd[1]' redblackthing.png
Re: Issue Flattening PSD to JPG with multiple alpha channels
Thanks for the speedy reply,
Also, how did you know to use layer/frame 1?
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.magick wrote:Try this command:
- convert 'redblackthing.psd[1]' redblackthing.png
Also, how did you know to use layer/frame 1?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issue Flattening PSD to JPG with multiple alpha channels
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.
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Issue Flattening PSD to JPG with multiple alpha channels
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!
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!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issue Flattening PSD to JPG with multiple alpha channels
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
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!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?
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?).
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.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!
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...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issue Flattening PSD to JPG with multiple alpha channels
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
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.fmw42 wrote:suspect you need to upgrade to 6.5.4-10 as there may be bugs or differences in older versions of IM
Still, this is a much better solution than I had before. Thanks for the help everyone.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issue Flattening PSD to JPG with multiple alpha channels
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)
convert redblackthing.psd[0] -background white -flatten -quality 100 redblackthing.jpg
perhaps it is your libjpeg?
(I am using libjpeg-6b.tar.gz)