Great work guys, this is very useful. A couple of questions:
1) Is the script optimized for enlarging as opposed to shrinking? I am asking because I see gammas greater than one flying around :-)
Hi Jack,
Indeed, it does best with enlarging, but it's not all that bad for shrinking either. Afterall, the first implementation, is a blend between a linear gamma and a gamma 3 (=
even darker brighter looking) image, which will be approx. gamma 1/2.2 reverted after the blend. As Nicolas said, it's hard to beat linear light for downsampling though.
2) If one works in AdobeRGB, is it enough to simply change all references of 'sRGB' to 'AdobeRGB' in the script?
To clarify, 'RGB' is used to linearize gamma (assuming sRGB source), and 'sRGB' is used to apply a gamma adjustment (assuming linear gamma source). A linearization followed by a non-linearization should therefore produce the exact same result as one started with. Only the pixel values that were changed in linear light will be different in the result.
For specific profile conversions, such as from Adobe RGB to something else and back, one must use the '-profile' option. That option allows to convert between two profiles (by specifying two ICC or ICM profiles), or assign a profile (by specifying a single profile) before saving the new image.
3) I sometimes generate a B&W image directly from a Bayer raw file. The resulting full resolution 'grayscale' TIF is still linear (gamma=1). Assuming one wanted to downsize only, could all the colorspace changing, gamma and cloning be replaced by a single line such as
convert "%~dpnx1" -filter LanczosRadius -distort Resize %Msize% ?
When starting with a (adjusted for Bayer CFA transmission differences) linear gamma image, one can indeed skip the prior 'RGB' linearization step, and directly execute the '-distort Resize' option with an amount. Different filters are available, all with different characteristics with regards to sharpness or blurriness and types of artifacts that are suppressed or boosted. The 'LanczosRadius' generally produces excellent results, so that's why it is used for the moment.
4) If one wanted a TIFF as an output would they simply leave out the -quality line?
Yes, I've added the -quality line to specifically maximize the compression quality of JPEGs and PNGs.
Cheers,
Bart