Page 1 of 1

Convert PSD or TIF to JPG ignore alpha

Posted: 2018-05-30T14:25:01-07:00
by JaredA
We have recently updated our RHEL ImageMagick from 6.7.8 to 7.0.3-8. Previous to the upgrade I was getting undesirable results in converting TIF files containing alpha channels converting to JPG format. Now post upgrade I am seeing the same with PSDs containing alpha channels to JPG.

The bad behavior is that the alpha channel is displayed in the JPG, here shown as the word "ALPHA".

PSD to JPG in PS: Image in IM: Image

Code: Select all

magick <input-file>[0] -intent relative -quality 95 -colorspace sRGB -strip
I've tried adding the various -alpha commands to try to ignore, such as Transparent, Remove, Off, Disassociate and have not yet had good results. Can anyone help? I want the alpha channel to be ignored.

In the User forum I was advised by fmw42 to report this as a bug. Link to the example: http://s000.tinyupload.com/?file_id=032 ... 3421656023

"Personally, I think there is a bug, since your alpha channel is disabled in the PSD file and should not show. But the IM developers will need to comment further."

Re: Convert PSD or TIF to JPG ignore alpha

Posted: 2018-05-30T14:29:24-07:00
by fmw42
See my comments at http://www.imagemagick.org/discourse-se ... =1&t=34024. There is a solution using -define psd:alpha-unblend=off, but that should not be needed. If the alpha channel is disabled in the PSD file, it should not be exported when converting in ImageMagick or there should be a different -define to enable or disable exporting disabled alpha channels.

Re: Convert PSD or TIF to JPG ignore alpha

Posted: 2018-05-31T14:06:36-07:00
by dlemstra
I stepped through the decoder with a debugger and I have no idea where can can detect that the alpha channel is disabled. Instead of layers this file contains a `FMsk` that we don't read. I could not find any good documentation about it.

Re: Convert PSD or TIF to JPG ignore alpha

Posted: 2018-05-31T14:19:09-07:00
by fmw42
It is an extra channel that is used as a mask or alpha channel. What does imagemagick do when there is no background transparency, but there is an enabled alpha channel? Does ImageMagick totally ignore PS alpha channels?

Re: Convert PSD or TIF to JPG ignore alpha

Posted: 2018-05-31T14:37:24-07:00
by dlemstra
This image only has a "merged" image and that image contains an alpha channel so we read it. I have no idea where can find that it is disabled.

Re: Convert PSD or TIF to JPG ignore alpha

Posted: 2018-05-31T14:43:55-07:00
by fmw42
Dirk,

Here are two test PSD images that I created. The first is 500x500 solid red with an alpha channel that is a smaller rectangle. The second is the same, but the alpha channel is disabled.

http://www.fmwconcepts.com/misc_tests/p ... pha_on.psd
http://www.fmwconcepts.com/misc_tests/p ... ha_off.psd

The following commands show the PSD converted to PNG. The alpha channel gets extracted and used in the PNG whether or not it is enabled or disabled in the PSD file. I also show the result of turning the alpha channel off to produce just the red image with no alpha channel.

Code: Select all

magick red_alpha_on.psd[0] red_alpha_on.png
Image

Code: Select all

magick red_alpha_off.psd[0] red_alpha_off.png
Image

Code: Select all

magick red_alpha_on.psd[0] -alpha off red_alpha_on_aoff.png
Image


Here are attempts to use alpha-unblend=off. But neither prevent the alpha channel from showing.

Code: Select all

magick -define psd:alpha-unblend=off red_alpha_on.psd[0] red_alpha_on_unblend.png
Image

Code: Select all

magick -define psd:alpha-unblend=off red_alpha_off.psd[0] red_alpha_off_unblend.png
Image

Version: ImageMagick 7.0.7-37 Q16 x86_64 2018-05-30 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps raw rsvg tiff webp x xml zlib

Re: Convert PSD or TIF to JPG ignore alpha

Posted: 2018-05-31T14:52:51-07:00
by fmw42
P.S. I reopened the PSD file that should have had the alpha channel enabled, but it gets disabled. I double checked and every time I save it with the alpha channel enabled and then reopen it, it shows as disabled. So perhaps there really is no difference, since saving the PSD file disables the alpha channel. I also see in the Save As dialog in PS, that there is a checkbox for saving the alpha channel. If not checked, the alpha channel is actually removed from the file when saving as opposed to be disabled for viewing.