Page 1 of 1
How to convert any random image to sRGB ?
Posted: 2011-11-16T09:05:56-07:00
by laurens_at_hol
Hi,
I have a webapplication where any random image can be uploaded. I want to convert every uploaded image to sRGB.
Can someone help me with this?
Can it be done for every image? What are the steps (commandline options)?
Thanks!
Re: How to convert any random image to sRGB ?
Posted: 2011-11-16T09:33:24-07:00
by Bonzo
I have never done it but try:
Code: Select all
convert input -colorspace sRGB output
http://www.imagemagick.org/script/comma ... colorspace
Re: How to convert any random image to sRGB ?
Posted: 2011-11-16T21:57:35-07:00
by anthony
Sorry NO.
the SRGB colorspace is miss-named in IMv6. It converts from sRGB to linear RGB.
This aspect will be fixed in a later stage of IMv7 development.
To convert a linear RGB image to sRGB you need to do this
Code: Select all
convert -size 100x100 gradient: \
-set colorspace sRGB -colorspace RGB gradient_sRGB.gif
See Gamma Correction and sRGB Colorspace
http://www.imagemagick.org/Usage/color_ ... perception
Re: How to convert any random image to sRGB ?
Posted: 2011-11-17T05:21:36-07:00
by laurens_at_hol
Thanks for your answers.
You are both suggesting to use the -colorspace option, but how about the -profile option then?
Don't I need to use the -profile option in combination with all kinds of profile files (like .icc), as is described in the documentation here:
http://www.imagemagick.org/Usage/formats/#color_profile
I'm not quite sure what to do.
Re: How to convert any random image to sRGB ?
Posted: 2011-11-17T18:23:45-07:00
by anthony
Profile is the better solution, if you can assign the original image a profile. Two profile options will convert the image, as documented in the link provided. Just remember that generally (but not always) any image read is should be assumed to be sRGB already.
The exceptions to this are mathematical or data images, greyscale masks (alpha channels are automatically thought of as linear), and image maps (for position or lighting effects). This makes reading, processing and writing images 'correctly' in IM (or any other image processor) tricky, as each image really needs to have that information specified.