I am trying to programmatically convert CMYK images to RGB.
If an image contains an embedded profile then I can convert to RGB like this:
convert source.eps -profile /path/to/sRGB.icm dest.jpg, which is great.
The problem is, if it doesn't then, according the the IM examples, the first use of -profile will be used to mean the profile of the source image, i.e. I should specify a second -profile flag to specify which profile to convert to. I guess this is the reason why the results look so bad.
In this case, using:
convert source.eps -colorspace RGB dest.jpg seems to work much better.
My questions are:
- What does -colorspace RGB do exactly, i.e. which color profiles are used with this option? Why/how does this seem to work reasonably well for images that do not contain an embedded color profile?
- What's the best practice for converting a CMYK image to RGB if the source color profile is not known?
- What's the easiest way to determine if an image does in fact contain a color profile, i.e. so that I then know which of the above approaches to take?
Any help much appreciated!
Thanks,
Martin
Converting CMYK to RGB with/without embedded profile
Re: Converting CMYK to RGB with/without embedded profile
I had this same issue a few months back. I was looking for a way to determine the actual
name of the color profile so my script could choose the appropriate profile for conversion.
I got no response to my post though, and never found the answer myself.
In the end, I found that if I used the more generic profiles, one for CMYK and the second
RGB, the results were fine. I suspect that if the color profile is not important enough to
be known, it's not important enough to be specified exactly.
name of the color profile so my script could choose the appropriate profile for conversion.
I got no response to my post though, and never found the answer myself.
In the end, I found that if I used the more generic profiles, one for CMYK and the second
RGB, the results were fine. I suspect that if the color profile is not important enough to
be known, it's not important enough to be specified exactly.
Re: Converting CMYK to RGB with/without embedded profile
Thanks Andrew. I came to the same conclusion (regarding generic profiles) and ended up doing it like this:
1) Determine if the image has an embedded image profile by using:
convert image.eps profile.icc
If this command doesn't return an error code, and the file profile.icc is created successfully, then the image contains an embedded profile.
[Surely there's a better way to detemine this?!]
2) If the image does contains an embedded profile then use it, i.e.:
convert input.eps -profile /path/to/sRGB.icm output.jpg
3) Otherwise, use any CMYK profile as input:
convert input.eps -profile /path/to/USWebCoatedSWOP.icc -profile /path/to/sRGB.icm output.jpg
This gives better results that using the -colorspace RGB option.
This seems pretty long-winded, and inefficient (especially the first step) so if anyone has any better ideas then please let me know!
Thanks,
Martin
1) Determine if the image has an embedded image profile by using:
convert image.eps profile.icc
If this command doesn't return an error code, and the file profile.icc is created successfully, then the image contains an embedded profile.
[Surely there's a better way to detemine this?!]
2) If the image does contains an embedded profile then use it, i.e.:
convert input.eps -profile /path/to/sRGB.icm output.jpg
3) Otherwise, use any CMYK profile as input:
convert input.eps -profile /path/to/USWebCoatedSWOP.icc -profile /path/to/sRGB.icm output.jpg
This gives better results that using the -colorspace RGB option.
This seems pretty long-winded, and inefficient (especially the first step) so if anyone has any better ideas then please let me know!
Thanks,
Martin