[SOLVED] Suggestion: IM7 colourspace CLI/API
Posted: 2012-04-17T08:37:17-07:00
I would like to suggest that IM7 use an ICC/colourspace interface (CLI/API) somewhat similar to NIP2/VIPS (see, e.g., http://libvips.blogspot.ca/2012/01/how- ... olour.html).
Specifically: Pick a "standard" anchor space. (Actually, more than one is probably needed, to deal with alpha and things that don't fit like color separation, multi-band images etc. In addition, when working in 8-bit, it may be a good thing to specifically have an sRGB and a "linear" RGB anchor space, which are the same except for that when converting to/from other colourspaces shortcuts are taken. Allow me to ignore these complications.) My first choice would be linear RGB(A), but sRGB(A) v2 would be acceptable. (NIP2/VIPS uses XYZ through Lab variants but I don't think this is a good choice for IM. GEGL/babl uses linear light RGB(A).) I understand this does not cover all possibilities. Unless otherwise "informed", or the image just does not fit into RGB(A), IM7 will pretend that what you have is just that. In the following, I assume the anchor space is linear RGB(A).
To convert into linear RGB(A) (or something understood as linear RGB(A)) using an ICC/ICM/whatever profile:with some way of toggling "use the embedded if there is one, and otherwise try some reasonable defaults until you find one that imports without an error", for example:or (which would consider the embedded profile to be the default if there is one).
To convert out of linear RGB(A) using a profile:with some way of toggling "export using the profile used to import this image, and otherwise try some reasonable defaults until it exports without an error", for example:or(since often that profile with be the import profile).
To convert to a different colorspace (default assumption being that it is from linear RGB(A), but otherwise going through linear RGB(A) to convert between the relevant pairs):(This is pretty much what IM7 does already.)
To "inform" IM7 that what is in the image belongs to some colorspace without doing any import/export/conversion:(This is pretty much what -colorspace did before IM7.)
No need to explain to me why you don't like this idea if you don't. I have not studied this issue carefully, and I'm not doing this to "win".
Specifically: Pick a "standard" anchor space. (Actually, more than one is probably needed, to deal with alpha and things that don't fit like color separation, multi-band images etc. In addition, when working in 8-bit, it may be a good thing to specifically have an sRGB and a "linear" RGB anchor space, which are the same except for that when converting to/from other colourspaces shortcuts are taken. Allow me to ignore these complications.) My first choice would be linear RGB(A), but sRGB(A) v2 would be acceptable. (NIP2/VIPS uses XYZ through Lab variants but I don't think this is a good choice for IM. GEGL/babl uses linear light RGB(A).) I understand this does not cover all possibilities. Unless otherwise "informed", or the image just does not fit into RGB(A), IM7 will pretend that what you have is just that. In the following, I assume the anchor space is linear RGB(A).
To convert into linear RGB(A) (or something understood as linear RGB(A)) using an ICC/ICM/whatever profile:
Code: Select all
-import PROFILE_NAME or LOCATION
Code: Select all
-import embedded
Code: Select all
-import default
To convert out of linear RGB(A) using a profile:
Code: Select all
-export PROFILE_NAME
Code: Select all
-export embedded
Code: Select all
-import default
To convert to a different colorspace (default assumption being that it is from linear RGB(A), but otherwise going through linear RGB(A) to convert between the relevant pairs):
Code: Select all
-colorspace COLORSPACE_NAME
To "inform" IM7 that what is in the image belongs to some colorspace without doing any import/export/conversion:
Code: Select all
-tag COLORSPACE_NAME
No need to explain to me why you don't like this idea if you don't. I have not studied this issue carefully, and I'm not doing this to "win".