Page 1 of 1

Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T18:35:30-07:00
by DnA915
I have a large number of multi-layer PSD files which contain alpha gradients. The color behind these gradients are black. This is a simplified form of what I am using:

Code: Select all

convert -background transparent source.psd -flatten  output.png
When I run this conversion, the color behind the alpha gradient becomes a strange, noisy gradient (not black), and the alpha, although it stays smooth, gets dimmer. In other words, the RBG values are not at all being preserved. Alpha is being dimmed, but not distorted as theses values are. My guess would be some sort of rounding error based on trying to extrapolate the color from the alpha as though it is trying to "unpre-multiply" the values.

Source example over grey
Image

Converted over grey:
Image

I used AfterEffects to do a render of RGB strait, where the alpha is ignored, and the problem is even more apparent:

Source:
Image

Converted:
Image

Any help is appreciated!

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T18:42:21-07:00
by fmw42
try

Code: Select all

convert -background transparent source.psd[0] -flatten  output.png
If that does not work, then post the original PSD file.

Please always provide your IM version and platform. Processing of PSD has been improved only in the last few releases.

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T19:20:38-07:00
by DnA915
I tried the exact command you gave and it gave a slightly different but still incorrect answer with the same RGB distortion.

Copyright Notice: This is owned by my company and I have permission to distribute this image for debugging purposed. This is not being released into the public domain and all rights are reserved

https://www.dropbox.com/s/1v99wscyqcva8h1/gun.psd?dl=0


Here is my version string:
Version: ImageMagick 6.9.6-4 Q16 x86_64 2016-11-10

Thanks for the help!

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T20:13:55-07:00
by fmw42
One of the IM developers will need to look at this. I get an abort trap on IM 6.9.6.4 and IM 7.0.3.6 on Mac OSX with the following:

Code: Select all

convert gun.psd[0] gun.png
Abort trap

Code: Select all

identify -verbose gun.psd[0]
Abort trap

But this may be a Mac only bug. Try the first command and see if it works for you

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T20:27:02-07:00
by DnA915
Are you sure you downloaded the file correctly? It downloaded and I did not see anything about an abort on the command line? Did you see if you could open it in preview after you downloaded it?

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T20:29:30-07:00
by fmw42
This may be a Mac Imagemagick only bug. One of the developers is working on it.

But try the first command and see if it works for you

Code: Select all

convert gun.psd[0] gun.png
What is your platform?

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T20:46:52-07:00
by DnA915
Yes, I am on mac. If it makes a difference, I have mine installed via the Homebrew package installer, so it could be a sub dependency versioning difference perhaps.

Code: Select all

brew install imagemagick
I am searching for a way to upgrade to V7 using homebrew to test there. If anyone else has V7 and can try this PSD, it would be very helpful too.

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T21:50:28-07:00
by snibgo
On Windows 8.1, I don't get an abort trap.

With v6.9.5-3, I get a bad shadow. With v7.0.3-5, the result looks good.

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T21:52:13-07:00
by DnA915
Thanks so much! I will work to get V7 installed and do it an alternate way if HomeBrew does not yet have an install formula. I will report back on the results.

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T21:56:57-07:00
by fmw42
Does this work for you on the current IM 6.9.6.4?

Code: Select all

convert gun.psd[0] gun.png
If not, then perhaps the fix was only included in IM 7 and not backported to IM 6. Or perhaps as I said it is a Mac issue and won't work on IM 7. It did not for me. I got an abort trap again. I install via source.

It also might be a Mac version issue, since I am on an old snow leopard.

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T23:21:41-07:00
by DnA915
Wow this is terrible...
Apparently, both MacPorts and Homebrew install only Imagemagick 6. I attempted to install from source, but was having trouble getting all the dependencies lined up manually. (Does anyone have an automated way of doing IM7 on Mac???). So I gave up and downloaded the binary and installed it. It works great until you actually try to do something with it, then it just prints

Abort trap: 6

The new version: Version: ImageMagick 7.0.3-5 Q16 x86_64 2016-10-18

Really frustrated now because it seems there is no way to get this actually installed on OSX for V7. I am on macOS Sierra btw. Not sure where to go from here so if anyone has any tips, please let me know.

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T23:41:06-07:00
by snibgo
Sorry, I know nothing about Macs.

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-12T23:58:24-07:00
by DnA915
So I booted up the old Ubuntu VM in VirtualBox and installed from source (which was exceptionally easy compared to all the Mac pain), and it works perfect on V7. Really wish the mac version of V7 would get some love from the devs, but for now, it looks like I'll be moving things back and forth between the VM. If anyone has tips on getting a smooth V7 Mac version working, please let me know. To everyone else, thanks for the help!

Re: Alpha not being handled correctly when flattening a gradient from a PSD file

Posted: 2016-11-13T01:26:13-07:00
by fmw42
As far a I know neither Homebrew nor MacPorts install IM 7, only IM 6.That is why I have installed via source. If you are interested, see viewtopic.php?f=1&t=21502&p=88202&hilit ... rts#p88202