Page 1 of 1

Is this expected, or a bug?

Posted: 2009-04-19T15:34:29-07:00
by pmurray
Hi, just wondering if this behaviour is expected? If I ping the image it always says it's in Greyscale, even though the file is not. If I read the entire image, it correctly returns false.

I get the same true/false result with any RGB file I try.

Code: Select all

irb(main):001:0> require 'RMagick'
=> true
irb(main):002:0> i = Magick::Image.ping('test.jpg').first
=> test.jpg JPEG 1600x1084 1600x1084+0+0 DirectClass 8-bit 485kb
irb(main):003:0> i.grey?
=> true
irb(main):004:0> i.colorspace
=> RGBColorspace=1
irb(main):005:0> i = Magick::Image.read('test.jpg').first
i=> test.jpg JPEG 1600x1084 1600x1084+0+0 DirectClass 8-bit 485kb
irb(main):006:0> i.grey?
=> false
irb(main):007:0> Magick::Version
=> "RMagick 2.9.1"
irb(main):008:0> Magick::Magick_version
=> "ImageMagick 6.5.1-1 2009-04-20 Q16 http://www.imagemagick.org"
Interestingly, it works as expected with a much older version of ImageMagick,

Code: Select all

irb(main):001:0> require 'RMagick'
=> true
irb(main):002:0> puts Magick::Version, Magick::Magick_version
RMagick 2.3.0
ImageMagick 6.3.7 03/31/08 Q16 http://www.imagemagick.org
=> nil
irb(main):003:0> Magick::Image.ping('test.jpg').first.grey?
=> false
irb(main):004:0> Magick::Image.read('test.jpg').first.grey?
=> false

Re: Is this expected, or a bug?

Posted: 2009-04-19T19:06:37-07:00
by magick
Ping() is light-weight and only reads the image meta-data but not the image pixels. Therefore the attributes associated with the pixels are undefined. If you want to attributes associated with the image pixels, use Read() instead of Ping().

Re: Is this expected, or a bug?

Posted: 2009-04-19T19:59:10-07:00
by pmurray
Is there anyway I can tell if an Image is a greyscale one without read'ing the entire image? As I'm dealing with some large images, this gets very slow.

How come this behaves as expected in prior versions? Does ping actually load the image data in those cases?

Re: Is this expected, or a bug?

Posted: 2009-04-19T22:23:08-07:00
by fmw42
in command line,

convert image -ping -format "%[colorspace]" info:

e.g.
convert rose: -colorspace gray rose_gray.png
convert rose_gray.png -ping -format "%[colorspace]" info:

returns:
Gray