M
Mike Meng
Hi all,
I want to determine the geometry of an image. The image file may be
in local harddisk or on web. So I use open-uri and
Magick::Image::from_blob to do that work, here is the code:
open('<path or URI of image file>') { |f|
image = Magick::Image::from_blob(f.read).first
puts "Width: #{image.columns}; Height: #{image.rows}"
}
For most of the cases, this works well. However, we I tried to read an
JPEG generated by my Ricoh Caplio digital camera, it failed and emitted
these message:
---------- code ----------
E:/workspace/ruby/idapted/testrmg.rb:6:in `from_blob': JPEG datastream
contains
no image `' (Magick::ImageMagickError)
....
-----------------------------
Surprisingly enough, if I use Magick::Image::read method to read the
same image file directly from harddisk, everything is fine, here is the
code:
---------- code ----------
g = Magick::Image::read('<local file only>').first
puts "Width: #{g.columns}; Height: #{g.rows}"
-----------------------------
Why do Image::read and Image::from_blob make differeces? How to
determine the geometry of a remote image?
Any comment is appreciated. Thanks!
I want to determine the geometry of an image. The image file may be
in local harddisk or on web. So I use open-uri and
Magick::Image::from_blob to do that work, here is the code:
open('<path or URI of image file>') { |f|
image = Magick::Image::from_blob(f.read).first
puts "Width: #{image.columns}; Height: #{image.rows}"
}
For most of the cases, this works well. However, we I tried to read an
JPEG generated by my Ricoh Caplio digital camera, it failed and emitted
these message:
---------- code ----------
E:/workspace/ruby/idapted/testrmg.rb:6:in `from_blob': JPEG datastream
contains
no image `' (Magick::ImageMagickError)
....
-----------------------------
Surprisingly enough, if I use Magick::Image::read method to read the
same image file directly from harddisk, everything is fine, here is the
code:
---------- code ----------
g = Magick::Image::read('<local file only>').first
puts "Width: #{g.columns}; Height: #{g.rows}"
-----------------------------
Why do Image::read and Image::from_blob make differeces? How to
determine the geometry of a remote image?
Any comment is appreciated. Thanks!