possible bug -set colorspace:gray=false IM 6.9.2.3 Q16 Mac OSX

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
User avatar
fmw42
Posts: 25266
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug -set colorspace:gray=false IM 6.9.2.3 Q16 Mac OSX

Post by fmw42 » 2015-10-05T12:03:24-07:00

According to the changelog

2015-07-25 6.9.2-0 Dirk Lemstra <dirk@lem.....org>
Added "-set colorspace:auto-grayscale=false" that will prevent automatic conversion to grayscale inside coders that support grayscale.


But when I try the following I get an error message.

Code: Select all

convert rose: -colorspace gray -set colorspace:auto-grayscale=false rose_tmp.png
convert: missing an image filename `rose_tmp.png' @ error/convert.c/ConvertImageCommand/3227.

Am I not doing this correctly?

User avatar
dlemstra
Posts: 1563
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: possible bug -set colorspace:gray=false IM 6.9.2.3 Q16 Mac OSX

Post by dlemstra » 2015-10-05T14:51:39-07:00

It seems I made a typo in the ChangeLog (just pushed a patch to our GIT repository to fix this). It should be one of the following two:

Code: Select all

-define colorspace:auto-grayscale=false
-set colorspace:auto-grayscale false
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

User avatar
fmw42
Posts: 25266
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -set colorspace:gray=false IM 6.9.2.3 Q16 Mac OSX

Post by fmw42 » 2015-10-05T15:07:45-07:00

Ok. Thanks

But perhaps I do not understand what this should do. I thought it would save the file as type truecolor RGB and not grayscale

Code: Select all

convert rose: -colorspace gray -define colorspace:auto-grayscale=false rose_tmp.png
Image: rose_tmp.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: PseudoClass
Geometry: 70x46+0+0
Units: Undefined
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: Gray
Depth: 8-bit
Channel depth:
gray: 8-bit


Can you explain further what I can do to get a grayscale or more importantly a bilevel image to be saved as RGB? Can you also put some explanation on the -define section of the options page.

I had a client who was using my otsuthresh script to make a binary image. But his other software needs the image to be 0 and 255, but as RGB 8-bits.

User avatar
fmw42
Posts: 25266
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -set colorspace:gray=false IM 6.9.2.3 Q16 Mac OSX

Post by fmw42 » 2015-10-06T15:53:15-07:00

Thanks for posting the comments on the -define page:

"colorspace:auto-grayscale=on|off prevent automatic conversion to grayscale inside coders that support grayscale."

But then what am I doing wrong in my example above?

User avatar
dlemstra
Posts: 1563
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: possible bug -set colorspace:gray=false IM 6.9.2.3 Q16 Mac OSX

Post by dlemstra » 2015-10-07T12:53:40-07:00

It does not look like the PNG coder automaticly makes the image gray. But when you set the colorspace to gray you also change the -type of the image. I get the result that you want with the following command:

Code: Select all

convert rose: -colorspace gray -type truecolor rose_tmp.png
Image: rose_tmp.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: Grayscale
Base type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8/16-bit
Channel depth:
Gray: 8-bit
Channel statistics:
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

User avatar
fmw42
Posts: 25266
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -set colorspace:gray=false IM 6.9.2.3 Q16 Mac OSX

Post by fmw42 » 2015-10-07T13:58:31-07:00

Thanks. That helps for grayscale. But then under what conditions or circumstances does that -define work? Can you explain a bit further and give an example.

Also it does not work for bilevel.

Code: Select all

convert rose: -threshold 0 -depth 8 -type truecolor rose_tmp.png
Image: rose_tmp.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: PseudoClass
Geometry: 70x46+0+0
Units: Undefined
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: Gray
Depth: 8/1-bit


I think IM should allow -type (or some other mechanism) to override the base type internally determined by IM, so that palette, grayscale or bilevel could always be saved as truecolor, if desired by the user. Basically it lets any restricted type be saved or up-typed to a more flexible type.

Don't all image types support an (s)RGB type (except for GIF and PGM for example, the latter of which could be up-typed to PNM or PAM). But I suspect most users would be happy with JPG, PNG, and TIFF (and perhaps PSD).

Other opinions or comments are welcome.

User avatar
fmw42
Posts: 25266
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -set colorspace:gray=false IM 6.9.2.3 Q16 Mac OSX

Post by fmw42 » 2015-10-08T14:52:12-07:00

OK, after discussions with Dirk (dlemstra) we have this sorted out. PNG and TIFF do not need the define. PNG works fine with just PNG24:image.png. TIFF works fine if -type truecolor is added. For JPG and PSD, this define is needed.

Code: Select all

convert rose: -threshold 0 PNG24:rose_tmp.png
Type: TrueColor

Code: Select all

convert rose: -threshold 0 -type truecolor rose_tmp.tif
Type: TrueColor
Base type: TrueColor

Code: Select all

convert rose: -threshold 0 -define colorspace:auto-grayscale=false -type truecolor rose_tmp.jpg
Type: TrueColor

Code: Select all

convert rose: -threshold 0 -define colorspace:auto-grayscale=false -type truecolor rose_tmp.psd
Type: Palette

(IM 7 reports Type: Bilevel and Base type: Palette)

But is seems to fail for PSD.

Post Reply