Thanks fred, but I don't think my post got the point across, and I am still confused what the rules are, or in fact if there is a bug somewhere... 6.9.7-4
The first part of my example probably caused confusion, so lets start with a tif file which I want to consider as linear. My understanding is there is no meaningful gamma meta data in a tiff, so the only way to know it's linear is to put linear data in there in the first place?
Code: Select all
convert logo: logo.tif
convert logo: -set colorspace RGB logo.tif
convert logo: -colorspace RGB logo.tif
For example the first two commands leave an identical file because the gamma field is not set/changed, and no changes to the image have been made. The final command does change the image data, but the meta data still shows gamma=0.4545
But it doesn't matter I just what the next step to treated as if it was a linear file. So pick one of the commands above and THEN apply the following two commands, (the last one if your prefer). I expect the same result, but that does not happen, and I would like to understand why.
Code: Select all
convert logo.tif -strip -set colorspace RGB \
-fx "u?u:1" \
-separate \
\( -clone 0 -poly ".1,-1" -poly "1,1.65" \) -swap 0,3 -delete 3 \
\( -clone 1 -poly ".1,-1" -poly "1,1.65" \) -swap 1,3 -delete 3 \
\( -clone 2 -poly ".1,-1" -poly "1,1.65" \) -swap 2,3 -delete 3 \
-set colorspace RGB -combine -type TrueColor myfile.tif
Code: Select all
convert logo.tif -strip -set colorspace RGB \
-fx "u?u:1" \
-channel R -fx "(.1/u)^1.65" \
-channel G -fx "(.1/u)^1.65" \
-channel B -fx "(.1/u)^1.65" \
myfile2.tif
In the above examples I have told IM -set colorspace RGB after loading the file, before -separate and before -combine, so I expect linear outputs at all times?
fmw42 wrote: ↑2017-11-12T22:38:37-07:00
But it is aways best to use -set colorspace YYY before -combine and -colorspace XXX after -combine.
Code: Select all
convert logo.tif -strip -set colorspace RGB \
-fx "u?u:1" \
-separate \
\( -clone 0 -poly ".1,-1" -poly "1,1.65" \) -swap 0,3 -delete 3 \
\( -clone 1 -poly ".1,-1" -poly "1,1.65" \) -swap 1,3 -delete 3 \
\( -clone 2 -poly ".1,-1" -poly "1,1.65" \) -swap 2,3 -delete 3 \
-set colorspace RGB -combine -type TrueColor -colorspace RGB myfile3.tif
Yes If I add this first command I now get the same result, but this seems inconsistent with the way -separate works,is this how it is supposed to work, I cannot find once "correct" example in the documentation that covers this.
I am not sure why this needs to be so opaque?
Ideally some documentation that explains it like so:
file_on_disk.tif ---read--> data_in_memory, color_space_flags
data_in_memory, color_space_flags -----separate----> data_in_memory, color_space_flags
data_in_memory, color_space_flags ----combine----> data_in_memory, color_space_flags
data_in_memory, color_space_flags ----create_file----> new_file_on_disk.tif
covering each stage, with what is in the file, what is in memory and what is the status of the color space & gamma, whether the meta data in the file is relevant (when it's ignored or doesn't work), as the meta data is obviously affecting the result as when I now remove -set colorspace RGB from the following two examples I now get the same result as the myfile2.tif and myfile3, but it's different to myfile1.tif and its not obvious or intuitive why or a bug...
Code: Select all
convert logo.tif -strip \
-fx "u?u:1" \
-separate \
\( -clone 0 -poly ".1,-1" -poly "1,1.65" \) -swap 0,3 -delete 3 \
\( -clone 1 -poly ".1,-1" -poly "1,1.65" \) -swap 1,3 -delete 3 \
\( -clone 2 -poly ".1,-1" -poly "1,1.65" \) -swap 2,3 -delete 3 \
-combine -type TrueColor myfile4.tif
Code: Select all
convert logo.tif -strip \
-fx "u?u:1" \
-channel R -fx "(.1/u)^1.65" \
-channel G -fx "(.1/u)^1.65" \
-channel B -fx "(.1/u)^1.65" \
myfile5.tif