Page 1 of 1

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

Posted: 2015-10-05T12:03:24-07:00
by fmw42
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?

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

Posted: 2015-10-05T14:51:39-07:00
by dlemstra
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

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

Posted: 2015-10-05T15:07:45-07:00
by fmw42
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.

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

Posted: 2015-10-06T15:53:15-07:00
by fmw42
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?

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

Posted: 2015-10-07T12:53:40-07:00
by dlemstra
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:

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

Posted: 2015-10-07T13:58:31-07:00
by fmw42
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.

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

Posted: 2015-10-08T14:52:12-07:00
by fmw42
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.