Page 1 of 1

-set colorspace

Posted: 2012-11-18T10:46:14-07:00
by snibgo
From the thread viewtopic.php?f=4&t=21269:
magick wrote:To declare an image is linear RGB rather than sRGB, you can use the set option:

convert myimage.jpg -set colorspace RGB myRGBimage.jpg
This doesn't seem to work in 6-7-9-Q16 on Windows 7.

For example:

Code: Select all

convert rose: rose.tiff
convert rose: -set colorspace RGB rose2.tiff
convert -verbose -identify shows no differences, and the files process identically to commands such as -equalize.

Re: -set colorspace

Posted: 2012-11-18T11:34:11-07:00
by fmw42
-set colorspace is a setting and needs an operator such as -separate or -colorspace gray to have any effect, if I am not mistaken.

All that will happen is that the verbose info will show colorspace RGB if supported rather than sRGB for any give image format. The data will not change until some operator acts upon the colorspace set. I am not sure tiff supports linear RGB


convert rose: -set colorspace RGB tiff:- | identify -verbose -
Image: /tmp/magick-185OsYGHicV0QGs
Base filename: -
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 70x46+0+0
Units: PixelsPerInch
Type: TrueColor
Base type: TrueColor
Endianess: MSB
Colorspace: sRGB

But PNG does:

convert rose: -set colorspace RGB png:- | identify -verbose -
Image: /tmp/magick-188WcnyBWRhdmX9
Base filename: -
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: RGB

And it would appear that also GIF does:


convert rose: -set colorspace RGB gif:- | identify -verbose -
Image: /tmp/magick-250tsg1sCuF6RIu
Base filename: -
Format: GIF (CompuServe graphics interchange format)
Class: PseudoClass
Geometry: 70x46+0+0
Units: Undefined
Type: Palette
Endianess: Undefined
Colorspace: RGB

Re: -set colorspace

Posted: 2012-11-18T11:39:21-07:00
by snibgo
So the example magick gave doesn't work, and isn't supposed to?

Re: -set colorspace

Posted: 2012-11-18T11:45:44-07:00
by fmw42
His example at viewtopic.php?f=4&t=21269 was using jpg. And if it changes the colorspace in the verbose info, then that is all is should do.

convert myimage.jpg -set colorspace RGB myRGBimage.jpg

Testing:

convert rose: -set colorspace RGB jpg:- | identify -verbose -
Image: /tmp/magick-191VWI_JY1Mb1xU
Base filename: -
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB


So either jpg (and tiff) do not support linear RGB or there is a bug.

If the former, then the jpg example at the top should probably be changed to png, so that the verbose info shows linear RGB

Re: -set colorspace

Posted: 2012-11-18T11:51:14-07:00
by fmw42
However, I believe if you add some operator such as -colorspace gray, then you will see a difference, because the image is converted to some internal IM format that supports linear RGB and then the operator sees that and works accordingly, though the output (tiff or jpg) may still show sRGB.

By the way, there is a little information about color formats and sRGB, linear RGB, etc at http://www.imagemagick.org/script/forma ... colorspace, but it looks like it needs further enhancement about formats that do not support linear RGB, per se.

Re: -set colorspace

Posted: 2012-11-27T22:35:46-07:00
by anthony
-colorspace is an operator that effects the image, converting the data.

-set colorspace just changes how IM will view the data of the image. It does not actually change the data, just what that data is supoosed to represent.