IM can't tell that alpha channel is turned off in PSD file

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Bob Pickle
Posts: 20
Joined: 2013-11-11T08:52:56-07:00
Authentication code: 6789

IM can't tell that alpha channel is turned off in PSD file

Post by Bob Pickle »

Hi.

I was processing a large number of PSD files, and ran into problems with three of them. These three all had a background image layer with an alpha channel, and ImageMagick's incorrect output matched that alpha channel. However, in the PSD files, the alpha channel was turned off, deactivated, invisible, however you want to say it. But for some reason ImageMagick can't seem to tell that the alpha channel was off.

I am able to do the following as a workaround:

Code: Select all

convert \( -alpha off test.psd[0] \) test.png
But still, it seems like a bug. If the 0 layer is a composite of all the layers and does not include the alpha channel because it is turned off in the PSD, then it doesn't seem like I should have to turn off the alpha channel when using ImageMagick to further process the image. Why would ImageMagick act as if that image channel is on when it's off?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by fmw42 »

did you try

convert \( test.psd[0] -alpha off \) test.png

if that does not work, then post a link to your psd file and provide your IM version and platform
Bob Pickle
Posts: 20
Joined: 2013-11-11T08:52:56-07:00
Authentication code: 6789

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by Bob Pickle »

Sure, that works, just as well as \( -alpha off test.psd[0] \). But isn't it a bug that one would have to tell IM to ignore an alpha channel that is already off, deactivated, disabled, not used within that PSD? I can understand if the alpha channel was enabled, but it isn't. Why should I have to tell IM to ignore the alpha channel when it is already being ignored by the PSD?

I'm using the latest IM version on Cygwin under WinXP, and under CentOS.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by fmw42 »

Bob Pickle wrote:Sure, that works, just as well as \( -alpha off test.psd[0] \). But isn't it a bug that one would have to tell IM to ignore an alpha channel that is already off, deactivated, disabled, not used within that PSD? I can understand if the alpha channel was enabled, but it isn't. Why should I have to tell IM to ignore the alpha channel when it is already being ignored by the PSD?

I'm using the latest IM version on Cygwin under WinXP, and under CentOS.

Either post a link to your image or post the output from

identify -verbose test.psd[0]
Bob Pickle
Posts: 20
Joined: 2013-11-11T08:52:56-07:00
Authentication code: 6789

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by Bob Pickle »

Code: Select all

Image: test.psd
  Base filename: test.psd
  Format: PSD (Adobe Photoshop bitmap)
  Class: DirectClass
  Geometry: 886x1299+0+0
  Resolution: 150x150
  Print size: 5.90667x8.66
  Units: Undefined
  Type: TrueColorMatte
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  Channel statistics:
    Red:
      min: 48 (0.188235)
      max: 255 (1)
      mean: 159.585 (0.625823)
      standard deviation: 53.7489 (0.21078)
      kurtosis: -0.770784
      skewness: -0.19957
    Green:
      min: 2 (0.00784314)
      max: 255 (1)
      mean: 126.572 (0.496361)
      standard deviation: 53.1672 (0.208499)
      kurtosis: -0.747776
      skewness: -0.169755
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 83.6967 (0.328223)
      standard deviation: 49.8732 (0.195581)
      kurtosis: -0.814028
      skewness: 0.0614875
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 1.82133 (0.00714248)
      standard deviation: 21.1796 (0.0830574)
      kurtosis: 135.587
      skewness: -11.6999
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 155.758 (0.610816)
      standard deviation: 46.507 (0.18238)
      kurtosis: 11.4561
      skewness: -0.634761
  Alpha: srgba(125,104,75,0)   #7D684B00
  Rendering intent: Perceptual
  Gamma: 0.45455
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Interlace: None
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Compose: Over
  Page geometry: 886x1299+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: RLE
  Orientation: Undefined
  Properties:
    date:create: 2013-11-07T08:46:48-06:00
    date:modify: 2013-09-06T06:11:00-05:00
    dc:format: application/vnd.adobe.photoshop
    photoshop:ColorMode: 3
    photoshop:ICCProfile: sRGB IEC61966-2.1
    rdf:Bag:




    signature: 172faa8425a2a869fb93ef280280783b598604606098b480cd3a9c1954406453
    tiff:XResolution: 150
    tiff:YResolution: 150
    xmp:CreateDate: 2010-02-01T08:56:13-05:00
    xmp:CreatorTool: Adobe Photoshop CS5 Windows
    xmp:MetadataDate: 2013-09-01T18:34:33+03:00
    xmp:ModifyDate: 2013-09-01T18:34:33+03:00
    xmpMM:DocumentID: xmp.did:1BEA3D8F390FDF11844EBA7C64DE414F
    xmpMM:InstanceID: xmp.iid:5B61BEDC1B13E3119CCA93DA9C482AF2
    xmpMM:OriginalDocumentID: xmp.did:1BEA3D8F390FDF11844EBA7C64DE414F
  Profiles:
    Profile-8bim: 29974 bytes
    Profile-exif: 302 bytes
    Profile-icc: 3144 bytes
      Description: sRGB IEC61966-2.1
      Manufacturer: IEC http://www.iec.ch
      Model: IEC 61966-2.1 Default RGB colour space - sRGB
      Copyright: Copyright (c) 1998 Hewlett-Packard Company
    Profile-iptc: 95 bytes
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      City[1,90]: 0x00000000: 254700                                        -%
      unknown[2,0]: ▒[
    Profile-xmp: 15798 bytes
  Artifacts:
    filename: test.psd[0]
    verbose: true
  Tainted: False
  Filesize: 16.9MB
  Number pixels: 1.151M
  Pixels per second: 136KB
  User time: 0.172u
  Elapsed time: 0:09.484
  Version: ImageMagick 6.7.6-3 2012-04-28 Q16 http://www.imagemagick.org
I just verified in PhotoShop that the alpha channel of this layer is not visible.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by fmw42 »

Is the alpha channel actually a channel or is it background transparency?

If the former, then I guess IM does not know how to tell if it is disabled. It only knows that you have an alpha channel.

I just opened a file in PS CS (rather old) and added an alpha channel and saved the file to psd format. No matter what settings I use to enable or disable the alpha channel, IM does not see any alpha channel using IM 6.8.7.5 Q16 and identify -verbose image.psd
Bob Pickle
Posts: 20
Joined: 2013-11-11T08:52:56-07:00
Authentication code: 6789

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by Bob Pickle »

I'm using PhotoShop CS2.

I removed everything possible from test.psd and left two layers. It is at http://www.pickle-publishing.com/images/test.psd. If you check the channel palette, it says that there is an alpha channel that isn't visible. Remove that invisible channel, and IM will convert the PSD correctly. Leave that invisible channel, and IM does not convert the PSD correctly.
fmw42 wrote:If the former, then I guess IM does not know how to tell if it is disabled. It only knows that you have an alpha channel.
That could be it. I would have thought that the composite [0] layer already takes into account whatever effect the alpha channel does or does not have, but maybe it doesn't.

I just did some testing, and if a color channel is disabled, IM still uses it as well. And if I use PhotoShop to save the image as a PNG, invisible RGB channels get included as well, though the alpha channel issue does not occur.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by fmw42 »

Your image has two layers, one of which contains background transparency. It also has an alpha channel. IM is apparently using the two layers and ignoring the alpha channel, probably because it uses the alpha layer and not the alpha channel, though I always thought it was the other way around. IM can only get alpha from one or the other and not both.
Bob Pickle
Posts: 20
Joined: 2013-11-11T08:52:56-07:00
Authentication code: 6789

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by Bob Pickle »

Thanks so much for your help.

I'm not sure I understand.

1. Where in PhotoShop can I see that one of the layers had background transparency?

2. If IM is ignoring the alpha channel, why is the output correct after I delete the alpha channel?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM can't tell that alpha channel is turned off in PSD fi

Post by fmw42 »

Perhaps I misunderstand PS, but your two layers seem to have a transparent background.

As far as I can tell from my test and your image, IM is ignoring the alpha channel.


Try my test. Open any sRGB jpg image in PS. Add a new alpha channel and draw or erase some part so that it is black and white as an alpha channel. Save the file to psd. Use identify -verbose image.psd to look for alpha channel. For me there is none.
Post Reply