PSD to PNG convert, color change

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
UncleEricB
Posts: 9
Joined: 2014-09-08T13:17:41-07:00
Authentication code: 6789

PSD to PNG convert, color change

Post by UncleEricB »

I know there have been posts about this previously but I've followed them without success towards my problem. See:
viewtopic.php?f=1&t=23257
https://www.imagemagick.org/discourse-s ... =3&t=23313
viewtopic.php?f=3&t=23313

I'm on OS X 10.9.4 using ImageMagick 6.8.9-0 Q16 x86 (This is the latest I could get through Port as of 9/8/14).
I have print-optimized CMYK PSDs that I want to convert to PNGs.

Here is a screenshot of part of the PSD. This color is correct.
Image

And here is a screenshot of part of the PNG. This color is incorrect. And it isn't just greens. The reds and blues shift lighter as well.
Image

Here is the command I used to create the PNG. I've used a bunch of other options as well. Same color changes. I'm really interested in combining only certain layers but to keep the problem simple (no talk of missing masks on other layers), I converted the entire PSD and got the same color problem.

convert 3ozMKSteakGrillers_3D_P.psd -layers merge -background None 3ozMKSteakGrillers_3D_P_all.png

For comparison, I used the same command with the output going to 3ozMKSteakGrillers_3D_P_all.psd, so converting a PSD to a PSD, and the color was fine (not changed). My first guess is that the issue is PSD to PNG, maybe having to do with CMYK to RGB.

I used identify -verbose for both the PSD(good)http://ericatplay.com/work/PSD_good.txt and the PNG(bad)http://ericatplay.com/work/PNG_bad.txt.

The final piece of the puzzle is that I'm a programmer, not an artist or designer. I have a basic knowledge of colorspaces. I have Photoshop CS6 on my work computer if you need me to look up some information about the files that way.

Any thoughts? I'm hoping it is something obvious to a knowledgable person, like "You are converting to an 8-bit colorspace. Try this..." Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PSD to PNG convert, color change

Post by snibgo »

I suppose your screen shots are taken from PS.

Other folk know more about PSD than I do, but:

1. You are flattening all the layers together. Perhaps you only need one layer.

2. The PSD file is CMYK, with no embedded profile that IM can read. So the conversion to RGB is a simple arithmetical one. I suspect this causes the colour problem.

Can you tell PS to embed the working colour profile? Then you can convert it to sRGB profile.

If PS can't embed the profile, it should at least tell you what it is, so you can tell IM how to convert it:

Code: Select all

convert in.psd[0] -profile PSprofile.icc -profile sRGB.icc out.png
where PSprofile.icc is PS's working colour space.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD to PNG convert, color change

Post by fmw42 »

Please provide a PSD example of your input and the corresponding PNG output. You can upload to any free service such as dropbox.com and put the URLs here.

I am on OSX Snow Leopard with IM 6.8.9.7 Q16 and have an older PS CS, so I can check this out for your. Often it is a matter of the loss or change of the profile that PS has assigned, typically AdobeRGB. Or it might have to do with a CMYK to sRGB issue, requiring the use of profiles to maintain good color consistency.
UncleEricB
Posts: 9
Joined: 2014-09-08T13:17:41-07:00
Authentication code: 6789

Re: PSD to PNG convert, color change

Post by UncleEricB »

snibgo wrote:I suppose your screen shots are taken from PS.
Yes, they are from Photoshop
snibgo wrote:1. You are flattening all the layers together. Perhaps you only need one layer.<
Unfortunately I do need a few of the layers. If I do a PNG of all layers or only the ones I want, I get the same color problem so I thought it would be easier to discuss all layers here. I'm assuming anything that works for all layers will work for some...
snibgo wrote:2. The PSD file is CMYK, with no embedded profile that IM can read. So the conversion to RGB is a simple arithmetical one. I suspect this causes the colour problem.

Can you tell PS to embed the working colour profile? Then you can convert it to sRGB profile.
I'm not sure how to do this. I have the original PSD and its Document Profile is 'Untagged CMYK (8bpc)". There is no other source of information about the color in the file than what is in the file. I don't have a separate ICC file.

snibgo wrote:If PS can't embed the profile, it should at least tell you what it is, so you can tell IM how to convert it:
I think it is the "Untagged CMYK" above. I tried the command you gave with that and the sRGB.icc and convert choked that there were no such files. A search of my computer didn't turn up any files by those names either.

Thanks for the quick reply though!
UncleEricB
Posts: 9
Joined: 2014-09-08T13:17:41-07:00
Authentication code: 6789

Re: PSD to PNG convert, color change

Post by UncleEricB »

fmw42 wrote:Please provide a PSD example of your input and the corresponding PNG output. You can upload to any free service such as dropbox.com and put the URLs here.

I am on OSX Snow Leopard with IM 6.8.9.7 Q16 and have an older PS CS, so I can check this out for your. Often it is a matter of the loss or change of the profile that PS has assigned, typically AdobeRGB. Or it might have to do with a CMYK to sRGB issue, requiring the use of profiles to maintain good color consistency.
Thanks for your quick reply. I need to clear the release of the mechanicals before I can post them, alas. As I'm getting more responses, I'm thinking you are correct about the profiles.

The funny thing is that I can Save for Web from Photoshop CS6, choose the PNG24 preset and make sure Convert to sRGB is checked and I get a PNG with the correct colors. But I can't automate that process. I wish I knew what Photoshop was doing behind the interface to make this work!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PSD to PNG convert, color change

Post by snibgo »

Another possible source of colour change: the gamuts of CMYK and RGB are different. That is, some printed CMYK colours can't be shown on an RGB screen, and some screen colours can't be printed. I believe PS tries to show on the screen the best approximation to how the printed result will look. The file is CMYK, so this involves not only a CMYK->RGB conversion, but also with added processing for out-of-gamut colours. (In IM, this is the "-intent" option. See http://imagemagick.org/script/command-l ... php#intent )
snibgo's IM pages: im.snibgo.com
UncleEricB
Posts: 9
Joined: 2014-09-08T13:17:41-07:00
Authentication code: 6789

Re: PSD to PNG convert, color change

Post by UncleEricB »

Here is the latest -
My original PSD is 'untagged' meaning it does not have a color profile. I noticed that the good PNG exported from Photoshop CS6 via Save for Web has a profile called "sRGB IEC61966-2.1(8bpc)" So I downloaded a profile called "sRGB_IEC61966-2-1_black_scaled.icc" from http://www.color.org/srgbprofiles.xalter#v2 and used it to make two conversions.

To make a PNG:
convert 3ozMKSteakGrillers_3D_P.psd -layers merge -profile profiles/sRGB_IEC61966-2-1_black_scaled.icc 3ozMKSteakGrillers_3D_P_all_sRGB.png

To make another PSD:
convert 3ozMKSteakGrillers_3D_P.psd -layers merge -profile profiles/sRGB_IEC61966-2-1_black_scaled.icc 3ozMKSteakGrillers_3D_P_all_sRGB.psd

I opened up the PNG in Photoshop and the colors are wrong. I try to open up the new PSD in Photoshop and I get an error message, "The embedded ICC profile cannot be used because the ICC profile is invalid. Ignoring the profile."

I saved the original PSD as a copy so I could change out the graphics to something I could post online and I noticed an option to Embed Color Profile: U.S. Web Coated (SWOP) ... After some searching, I found that profile and others for download here: http://www.adobe.com/support/downloads/ ... ileID=3792

I tried using that profile but the colors are still wrong.
convert 3ozMKSteakGrillers_3D_P.psd -layers merge -profile profiles/Adobe\ ICC\ Profiles\ \(end-user\)/CMYK/USWebCoatedSWOP.icc 3ozMKSteakGrillers_3D_P_all_sRGB.png

Eric B.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PSD to PNG convert, color change

Post by snibgo »

... and I noticed an option to Embed Color Profile: U.S. Web Coated (SWOP) ...
That's it. PS embeds the profile in the file. Then you can use one "-profile" command to convert it to sRGB. (Your "-profile" command should give the sRGB.icc filename, not the CMYK SWOP filename.) Eg:

Code: Select all

convert in.psd -profile sRGB.icc -layers merge out.png
I'm not sure if "-layers merge" should come before or after the "-profile".

Your IM directory probably has an sRGB.icc file.
snibgo's IM pages: im.snibgo.com
UncleEricB
Posts: 9
Joined: 2014-09-08T13:17:41-07:00
Authentication code: 6789

Re: PSD to PNG convert, color change

Post by UncleEricB »

snibgo wrote:
... and I noticed an option to Embed Color Profile: U.S. Web Coated (SWOP) ...
That's it. PS embeds the profile in the file. Then you can use one "-profile" command to convert it to sRGB. (Your "-profile" command should give the sRGB.icc filename, not the CMYK SWOP filename.) Eg:

Code: Select all

convert in.psd -profile sRGB.icc -layers merge out.png
I'm not sure if "-layers merge" should come before or after the "-profile".

Your IM directory probably has an sRGB.icc file.
I tried "convert <sourcefile.psd> -profile profiles/sRGB_IEC61966-2-1_black_scaled.icc -layers merge <targetfile.png>" but got the same color errors.

Even though I had the choice of embedding the US Web Coated SWOP profile in saving the PSD, the default action was not to save it. And when I look at the assigned profile on the source PSD, "Don't Color Manage This Document" is checked off. So I think the US Web Coated SWOP profile is a red herring.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD to PNG convert, color change

Post by fmw42 »

If the PSD does not have a profile imbedded and it is cmyk, then you need two profiles, one to tell it it is cmyk (US Web Coated Swop) and the second to convert to sRGB.

Code: Select all

convert in.psd -profile path2/USWebCoatedSWOP.icc -profile path2/sRGB.icc -layers merge out.png
With current versions of IM, you can find out what profiles exist using the relevant string formats for profiles and profile:xxx or from the verbose information from identify, see
http://www.imagemagick.org/script/escape.php
UncleEricB
Posts: 9
Joined: 2014-09-08T13:17:41-07:00
Authentication code: 6789

Re: PSD to PNG convert, color change

Post by UncleEricB »

fmw42 wrote:If the PSD does not have a profile imbedded and it is cmyk, then you need two profiles, one to tell it it is cmyk (US Web Coated Swop) and the second to convert to sRGB.

Code: Select all

convert in.psd -profile path2/USWebCoatedSWOP.icc -profile path2/sRGB.icc -layers merge out.png
With current versions of IM, you can find out what profiles exist using the relevant string formats for profiles and profile:xxx or from the verbose information from identify, see
http://www.imagemagick.org/script/escape.php
WE HAVE A WINNER! I still don't understand how IM knows how to handle two -profile commands (first one goes towards sourcefile and second towards targetfile?) but it doesn't matter. I got the correct colors. Where do I vote up fmw42 as having the correct answer? :D Also thanks to snibgo.

For the record, here is the command I used to merge several layers in a profile-less CMYK print PSD into a PNG.

convert 3ozMKSteakGrillers_3D_P.psd[1] 3ozMKSteakGrillers_3D_P.psd[2] 3ozMKSteakGrillers_3D_P.psd[3] -profile profiles/Adobe\ ICC\ Profiles\ \(end-user\)/CMYK/USWebCoatedSWOP.icc -profile profiles/sRGB_IEC61966-2-1_black_scaled.icc -layers merge -background None -colorspace sRGB 3ozMKSteakGrillers_3D_P_NoWt.png

where a sub-directory called profiles/ held the profiles I downloaded. See my previous posts in this thread for the URLs.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD to PNG convert, color change

Post by fmw42 »

You should in general check your PSD files to see if they have a profile or not. If they do have a profile, then snibgo's one profile command is correct and you might get a wrong result by using two profiles.
UncleEricB
Posts: 9
Joined: 2014-09-08T13:17:41-07:00
Authentication code: 6789

Re: PSD to PNG convert, color change

Post by UncleEricB »

I'll check some more but I'm pretty sure they do not have profiles. I had another hiccup this morning. All my work yesterday was on my Mac. I copied all the files over to my Windows box (running Cygwin) and the colors are wrong again, although in a different way. I copied over the exact profile files I was using and the original PSD. But I'm sure it has something to do with profiles. I guess I need to use different one(s) under Windows.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PSD to PNG convert, color change

Post by snibgo »

Windows shouldn't need different profiles. Are you using the same version of PS? With all the same settings?
snibgo's IM pages: im.snibgo.com
UncleEricB
Posts: 9
Joined: 2014-09-08T13:17:41-07:00
Authentication code: 6789

Re: PSD to PNG convert, color change

Post by UncleEricB »

snibgo wrote:Windows shouldn't need different profiles. Are you using the same version of PS? With all the same settings?
I'm using the same PSD file. I'm not using Photoshop as part of my script. The (python) script generates a call out to ImageMagick. I tarred up my folder from my Mac and copied it over to my Windows box. Same files, same script, same profiles. Colors look different.
Post Reply