-set colorspace

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

-set colorspace

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set colorspace

Post 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
Last edited by fmw42 on 2012-11-18T12:35:13-07:00, edited 3 times in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -set colorspace

Post by snibgo »

So the example magick gave doesn't work, and isn't supposed to?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set colorspace

Post 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
Last edited by fmw42 on 2012-11-18T12:37:34-07:00, edited 3 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set colorspace

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: -set colorspace

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply