Page 1 of 1

Black and White.. different with new version of IM

Posted: 2013-03-15T09:52:55-07:00
by dognose
So, I'm converting an image to black and white..
I'm getting a much darker image now with IM 6.8.2-10
command I'm using: mogrify -colorspace gray image.jpg

Any idea on what's going on here? Has the colorspaces changed?

Image

Version: ImageMagick 6.7.0-0 2011-05-24 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP

Image

Version: ImageMagick 6.8.2-10 2013-03-15 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP Modules
Delegates: bzlib djvu mpeg fontconfig freetype gslib jng jp2 jpeg lcms lqr openexr pango png ps rsvg tiff wmf x xml zlib

Image

Re: Black and White.. different with new version of IM

Posted: 2013-03-15T10:07:17-07:00
by snibgo
I don't use mogrify, but the cure is probably "-set colorspace RGB" to prevent a conversion from sRGB to RGB.

Re: Black and White.. different with new version of IM

Posted: 2013-03-15T11:52:08-07:00
by dognose
yeah, that works. I have lots of scripts, is there an easy way to set RBG as the default instead of sRBG gobally?

Re: Black and White.. different with new version of IM

Posted: 2013-03-15T12:08:29-07:00
by snibgo
No. The issue is that IM thinks that colour images are sRGB, unless told otherwise, but that monochrome images should be RGB.

The problem arises because most image file formats don't have a flag that says whether they are sRGB or RGB, so all software has to guess. Apparently there is a standard somewhere that says monochrome images should be regarded as RGB. As far as I know, IM is the only software that complies with this "standard", which means it is de facto non-standard.

If you compile your own IM, perhaps you can change your local copy.

Re: Black and White.. different with new version of IM

Posted: 2013-03-15T12:18:53-07:00
by dognose
Yeah, I do build my own version. So, I guess I'm wondering how to go back to the old behavior. Is there a compile flag?

Re: Black and White.. different with new version of IM

Posted: 2013-03-15T12:29:40-07:00
by snibgo
Sorry, I don't know.

Re: Black and White.. different with new version of IM

Posted: 2013-03-15T13:33:22-07:00
by fmw42
The issue is that since about IM 6.7.8.3 grayscale images have been linear rather than non-linear. So use -set colorspace RGB -colorspace gray to convert to gray.

See
http://www.imagemagick.org/script/forma ... colorspace
viewtopic.php?f=4&t=21269

Re: Black and White.. different with new version of IM

Posted: 2013-03-17T06:12:05-07:00
by dognose
I understand the change, I'm just wondering how to go back to the previous default with out having to downgrade.
This seems like a pretty big change, and I'm seeing a lot of downstream problems caused by this.. It just seems
there should be an easier way to set the default colorspace... than having to set this in hundreds of scripts.

Re: Black and White.. different with new version of IM

Posted: 2013-03-17T07:13:04-07:00
by snibgo
I see your point.

"-set colorspace RGB" is a kludge, because we use it merely to prevent the conversion from sRGB to RGB. Most colour images are sRGB, and should be processed as such. (Remember that there are other colorspaces such as CIELab and HLS, and conversions to/from these must work correctly.) It seems to me that most monochrome images are also sRGB, and should be processed as such.

If there was some kind of global switch for ImageMagick, I'd like it to mean: "Treat monochrome as sRGB".

Re: Black and White.. different with new version of IM

Posted: 2013-03-17T10:33:54-07:00
by fmw42
My understanding is that the change was made to follow certain standards that dictate that grayscale images should be linear rather than non-linear. IM is trying to honor such color and grayscale standards that are dictated by those industries.

I had to modify many of my scripts to add a version trap to use -set colorspace RGB before converting to grayscale or other colorspaces and separating channels. So I understand your comments.

The only suggestion I could make might be to have an IM compile time option or IM Environment Variable (see http://www.imagemagick.org/script/resou ... nvironment) that could be used to set conversion to grayscale to non-linear. But this would have to be decided by the IM developer and I do not know how much effort that would involve.

I believe that there is a new setting coming out in the next release, -intensity, that would allow you to convert to linear or nonlinear grayscale (or use before some operator such as -threshold). See http://www.imagemagick.org/script/comma ... #intensity.
But I am not sure that helps your situation. The compile time or Environment Variable seems to me to be the best way to go.

Perhaps you might repost in the Developers forum.