Incorrect use of user-defined channels converting PSD files

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.
brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2016-11-09T13:32:54-07:00

When converting from a PSD to an image type that supports transparency like PNG, IM 6.9.6-4 is incorrectly interpreting user-defined channels as being transparency channels.

As far as I know, user-defined channels, with the exception of spot color channels, in Photoshop do NOT affect the appearance for most color modes, RGB, CMYK, bitmap, grayscale, Duotone, LAB. ImageMagick seems to be reading the channels and blending the pixel data into its alpha data. This often results in images with incorrect transparent or blank areas.

Even in the case of spot color channels, IM is treating them as transparency data.

To repro:

convert tomato.psd[0] tomato.png

Observe that the png is missing the first o. That's because IM is incorrectly using the user-defined alpha channel when rendering.

I have a patch, but I'm not sure about the submission process. It _only_ applies to converting the merged layer, but you might want to apply it to all processing.

Here is a link to my sample file: https://drive.google.com/open?id=0B5UZO ... k9tYkVXWVE

Any information on how to submit a patch is appreciated. Here is my patch:

https://drive.google.com/open?id=0B5UZO ... 0VBcmU5cXM

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-01-09T13:24:28-07:00

I would love to get some feedback on this.

User avatar
fmw42
Posts: 22091
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Incorrect use of user-defined channels converting PSD files

Post by fmw42 » 2017-01-09T14:06:57-07:00

Perhaps you could provide your input and output image and the exact code you used.

Have you seen the new defined for PSD files at http://www.imagemagick.org/script/comma ... php#define? Perhaps one of those will fix your processing issue.

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-01-10T21:18:22-07:00

Thanks for your response.

The input image is at https://drive.google.com/file/d/0B5UZO4 ... VXWVE/view.

The output image is at https://drive.google.com/file/d/0B5UZO4 ... sp=sharing.

The command line I used to convert is:

convert tomato.psd[0] tomato.png

I have tested the links while logged out of google, and they seem to work, but let me know if they don't.

Thanks for the link to the options. I am currently using psd:alpha-unblend=off in production, but it does not fix this problem which I think is the result of a misinterpretation of user-defined channels.

User avatar
dlemstra
Posts: 1383
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Incorrect use of user-defined channels converting PSD files

Post by dlemstra » 2017-06-26T14:19:38-07:00

We have read the photoshop file format specifications (http://www.adobe.com/devnet-apps/photos ... matashtml/) and the specifications don't mention how we should interpret the extra channel. We have various test files where that extra channel is the alpha channel. This is the first file where the extra channel does not appear to be an alpha channel. I don't know how we could detect that your file has no alpha channel.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

User avatar
fmw42
Posts: 22091
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Incorrect use of user-defined channels converting PSD files

Post by fmw42 » 2017-06-26T14:47:27-07:00

dlemstra wrote:
2017-06-26T14:19:38-07:00
We have read the photoshop file format specifications (http://www.adobe.com/devnet-apps/photos ... matashtml/) and the specifications don't mention how we should interpret the extra channel. We have various test files where that extra channel is the alpha channel. This is the first file where the extra channel does not appear to be an alpha channel. I don't know how we could detect that your file has no alpha channel.
I am not sure what he wants the extra channel to become. But you could add a new define that allows the user to decide if the extra channel is alpha or not.

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-10-21T12:28:10-07:00

One thing to note is that this only applies to reading the merged layer (skip_layers == MagickFalse). In this case, as the comment in the code states, "The first alpha channel in the merged result contains the transparency data for the merged result." Any further extra channels are user-defined and are not used for rendering. This may not be part of the spec, but it seems to be empirically true based on testing.

dlemstra, can you tell me where I can get some of the files you are testing with and the tests that you run? Are they part of source on github?

I have many sample files where the creative professional saves hidden changes in (sometimes numerous) user-defined channels. There is no way to tell photoshop to save the file with the channels enabled, but presumably the creative can take that work in the extra channels and add it into the visible channels.

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-10-21T12:57:01-07:00

fmw42, I am not proposing to ignore the alpha channel, just the extra channels beyond the alpha channel. These are user-defined channels and not used for rendering the PSD by photoshop. When you open the sample in photoshop, the extra channel is not visible. You can enable the channel temporarily, but even if you resave and open again, the channel will not be visible.

What I'm trying to do is create accurate thumbnails of photoshop files, typically jpegs or pngs. I have many examples of files with user-defined channels that exhibit this problem. They have been created both in-house and by our customers. Indeed, it is fairly simple to create an example myself.

Would it help to give you steps to create a file in photoshop that exhibits this problem?

User avatar
fmw42
Posts: 22091
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Incorrect use of user-defined channels converting PSD files

Post by fmw42 » 2017-10-21T13:15:51-07:00

When you convert the psd file to png or jpg, what should happen to the extra channels and what is currently happening that is not correct.

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-10-21T14:25:29-07:00

It should look the way Photoshop displays the psd when you initially open it in Photoshop. Photoshop always disables the user-defined channels on opening the file - they don't affect the way it displays. They cannot be permanently enabled by saving the file. They should be ignored.

The first 'o' should be displayed.

User avatar
fmw42
Posts: 22091
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Incorrect use of user-defined channels converting PSD files

Post by fmw42 » 2017-10-21T14:47:43-07:00

I still do not understand. What is going wrong? What is currently happening when you convert a PSD with extra channels to PNG or JPG? Does it include the extra channels in the PDS flattened [0] layer or is it corrupt in some way?

Perhaps it would be best if you provide a PSD file that has an extra channel and the result of conversion to JPG or PNG and the exact command line you used. That way the IM developers can check it out.

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-10-21T15:16:59-07:00

Gosh, I have provided the PSD and the PNG output as well as the command line for the conversion in the earlier posts on this thread.

I don't understand. You have asked me for these already and I provided them. Are you unable to access them?

Here is the information that I provided above:

The input image is at https://drive.google.com/file/d/0B5UZO4 ... VXWVE/view

The output image is at https://drive.google.com/file/d/0B5UZO4 ... sp=sharing

The command line I used to convert is:

convert tomato.psd[0] tomato.png

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-10-21T15:22:30-07:00

I am really puzzled that you keep asking me for a PSD file with an extra channel when I keep sending you a link to a sample. Do posts with links get filtered out or something? Is there a better way for me to send you a sample file?

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-10-21T16:04:57-07:00

I'll try this with dropbox. Here is the sample PSD:

https://www.dropbox.com/s/a5pzltii4m5n6 ... sd?dl=0&m=

Here is the converted PNG:

https://www.dropbox.com/s/2aqbuq6r0asu6 ... ng?dl=0&m=

I used:

> convert tomato.psd[0] tomato.png

brooksrichardbrown
Posts: 22
Joined: 2016-11-09T11:32:58-07:00
Authentication code: 1151

Re: Incorrect use of user-defined channels converting PSD files

Post by brooksrichardbrown » 2017-10-21T16:13:06-07:00

How can I provide you a sample? I have tried sending links, but you don't seem to get them. Attachments are disabled in this forum. Please advise.

Post Reply