-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong colors when converting .pam images #7548
Comments
Your PAM image is CMYK. PNG does not support that. It only uses RGB. So convert your image before saving using the generic -colorspace sRGB. You will get different results depending how you convert as below using the generic approach or using profiles.
Or use profiles. Your image does not have any assigned profile, so I add the best one that I know for CMYK for the input and then a sRGB one for the output. There are many CMYK and many RGB profiles that you can use to tune the result.
Some tools may convert it automatically. |
Thanks for the reply, Fred. The following command gave me the desired output (where desired means one that matches mupdf-gl): I obtained the profiles from
According to you, does ImageMagick require any changes so that it can handle such conversions better? (I don't know anything about colorspace or color profiles.) |
Sorry, I do not know what you mean by "does ImageMagick require any changes so that it can handle such conversions better?" The profile method is the best to use. If your input image has a CMYK profile, you do not need the -profile USWebCoatedSWOP.icc unless you want to convert to that input profile. |
Sorry for not being clear. I wanted to ask whether ImageMagick can be "patched" so that it can automatically handle the conversion (with the correct colors) when I use If no change needs to be made to the ImageMagick codebase, I can close the issue because the problem has been solved for me. |
As far a I know there is no fix or change that can/will be made for that. A developer will have to comment further or someone who know the code better. It seems that IM uses -colorspace sRGB (or something like it) automatically to do the conversion. It would have no way to know what profiles you want to use and in general leaves these things to the user so as to be as flexible as possible. Here is my conversion
As you can see it did the conversion, but the results are like using -colorspace sRGB in the command. You can tell it did the conversion as the colors are not negated in the output, which is typical of CMYK input which is interpreted as RGB output. If you want something automatic, you would have to write a script that detects the PNG output and CMYK input and adds the profile code. |
Well, I just want the converted image to look as similar to the original image as possible. I don't really have preference for a particular profile. |
There is no automated method currently other than a script. Use the profiles that I suggested. |
I understand. But your "original image" is actually an RGB image converted from CMYK, and we don't know how that conversion was done, or whether it was "correct".
IM does automatically handle the conversion, but it doesn't know how to do this correctly. There is no definition of "correct". As @fmw42 says, there is no embedded ICC CMYK colour profile so one possibility is to assign a guessed profile, and convert to some sRGB profile. But this might be the wrong action (eg if the CMYK image was generated by |
Do you think that IM should show a warning in this case (when the color profile is not embedded and IM is not confident of the colors used)?
If I understand it correctly, IM is using a guessed profile even now. Otherwise, it won't be able to convert the image, right? As Fred said, USWebCoatedSWOP.icc is the best for CMYK. So, shouldn't this be the default? By the way, I still don't understand why the choice between (Sorry if I am being too noob.) |
IM is not using profiles. It uses a direct map probably just -colorspace sRGB. I said USWebCoatedSWOP.icc was my best guess for CMYK. It works adequately for me. It should not be the default. That should be left to the user. |
No. If your command doesn't include IM's default method for converting between RGB and CMYK uses simple arithmetic. When the colours are normalized to [0,1]:
The arithmetic used in conversions with I don't have good data on this, but I suspect the most common ICC CMYK profiles depend on where the image originated: USA (US*.icc), Europe (*FOGRA*.icc), or Japan (Japan*.icc). |
Thanks for your reply. It makes things clearer to me.
In my opinion, this makes an even stronger case for adding a warning when the input image doesn't contain a profile. The warning can read something like "The input image does not have any embedded CMYK colour profile. If the colors in the output image look distorted, try using different color profiles."
This still remains a doubt. |
But IM doesn't know if you want the output file to be encoded as sRGB or something else. |
Regardless of how the colors are encoded in the output file, they should look the same, right? |
No, different output profiles may look different. |
Ok, it seems that adding a warning is the only thing that IM needs to do. |
Doubt it will happen as the way IM works is to leave things to the user. There is no way to know what the user wants in all cases. |
ImageMagick version
ImageMagick 7.1.1-36 Q16-HDRI x64 852a4e9:20240727
Operating system
Windows
Operating system, version and so on
Windows 11 Build No. 10.0.22631-SP0
Description
When converting a .pam image to .jpg or .png using ImageMagick, the colors in the jpg and png are different.
The .pam image was extracted from a PDF file by using
mutool extract
. I don't know how to open .pam image files but the colors in the jpg and png files are different from the PDF and also different from each other.PDF (as displayed in
mupdf-gl
):JPG (as displayed in IrfanView & Microsoft Photos):
PNG (as displayed in IrfanView & Microsoft Photos):
Steps to Reproduce
magick test.pam test.png
magick test.pam test.jpg
Images
test.zip
This zip file contains the input image (test.pam) as well as the two output images (test.png and test.jpg).
The text was updated successfully, but these errors were encountered: