Eric has pointed out particularly about resizing, but similar problems would apply to any other operation which does algebraic operations on pixel values. Still, for the time being I'm thinking about resizing.
What I want to know is: Can ImageMagick resize an image taking into account a colour profile which I say that the image has?
Can I say to ImageMagick: Hey ImageMagick, this here image uses the sRGB colour space. Can you resize it to 50% (linear-dimension) and give me back an sRGB image? Oh, and by the way, when you do algebraic operations on pixel values, you must do that in the linear space.
So far the best I have come up with is similar to the example on Eric's page:
Code: Select all
convert in.png -depth 16 -gamma 0.454545454545 -resize 50% -gamma 2.2 -depth 8 out.png
But we know that sRGB actually uses a two zone system whereby the low values are mapped linearly, and higher values use a gamma of 2.4. (Also the linear zone uses a coefficient of 12.92, meaning that 16 bits should be fine for representing the bottom end of the space assuming 8-bit sRGB values.)
So the question is: Rather than approximating with a 2.2 gamma, can we not do it properly and apply the actual defined mappings between sRGB linear space, and if so, how?
And secondarily to that: Given that sRGB is prevalent, why do softwares (including ImageMagick) not assume sRGB by default if no colour profile is present, and act accordingly? i.e. Why do most softwares just assume they can do linear algebraic operations on pixel values when in fact in 2010 most untagged images will be (highly non-linear) sRGB images?
Without wishing to see pre-emptively ungrateful, replies along the lines of "Go and read up about colour profiles" are probably not going to solve my issue. I tried reading about colour profiles but it seemed to end up leaving me with more questions than it answered.
If what I am asking for is possible, then it would be nice to have an example ImageMagick command-line recipe which would do it.
What I am thinking, expressed in fictional (but hopefully obvious-meaning) directives would go as follows:
Code: Select all
# NOTE: pseudo-code! This will not actually work!
convert in.png -depth 16 -convert-sRGB-to-linear -resize 50% -convert-linear-to-sRGB -depth 8 out.png
Alternatively, it could work as:
Code: Select all
# NOTE: pseudo-code! This will not actually work!
convert in.png -actually-take-account-of-colorspace sRGB -resize 50% -out.png
Though of course it could be that I am suffering from an understanding problem, which is scenario I'm prepared to consider given that at the minute it seems to me that there seems to be something of an elephant in the room.
Bill