Converting anything to RGB correctly
Posted: 2010-06-19T04:57:12-07:00
I have all sorts of images (CMYK, AdobeRGB, RGB, with and without profiles). I need to convert them all to RGB.
First, I just addressed the CMYK problem, and did this:
However, if the image has a profile, I understand I would get better results if I used it.
(also, if the image is already in RGB, is it correct to assume that "-colorspace RGB" will do nothing?)
Then I encountered AdobeRGB images, for which it seems "-colorspace RGB" doesn't help, and I need to use the embedded profile.
(Is there always an embedded profile in AdobeRGB? If not, how can I find out if the image is sRGB or AdobeRGB?)
It seems i can find out if there is a profile with something like
Now what is the correct conversion? I am quite confused with the contradictory information I find about the use of profiles in the convert command, and would like to make sure that my script will do the right thing.
For example, the documentation says
Then I wonder if I need an output profile at all. If I do -colorspace RGB, is there any point in embedding an RGB profile in the output file?
Thanks for any clarifications you have to offer.
First, I just addressed the CMYK problem, and did this:
Code: Select all
convert -colorspace RGB -resize $size "$f" "photos/$name-$size.jpg"
(also, if the image is already in RGB, is it correct to assume that "-colorspace RGB" will do nothing?)
Then I encountered AdobeRGB images, for which it seems "-colorspace RGB" doesn't help, and I need to use the embedded profile.
(Is there always an embedded profile in AdobeRGB? If not, how can I find out if the image is sRGB or AdobeRGB?)
It seems i can find out if there is a profile with something like
Code: Select all
if convert "$file" "$profile" 2>/dev/null ; then
# convert using the profile
else
# no profile, so convert without
fi
For example, the documentation says
And numerous examples on the web suggest different things, also changing the order of the options (sometimes the -profile and/or -colorspace options are before the input file, sometimes between the input and the output)....then given two profile conversions is a bad idea. For example
convert cmyk_image.jpg -profile "CMYK.icc" -profile "RGB.icc" output_image.jpg
Will result in a CMYK -> CMYK -> RGB conversion
Then I wonder if I need an output profile at all. If I do -colorspace RGB, is there any point in embedding an RGB profile in the output file?
Thanks for any clarifications you have to offer.