Invalid geometry string in change_geometry


#1

I get the following error at the browser:

ArgumentError in ImagesController#upload
invalid geometry string `110×’

… for the call to change_geometry with an explicit size (‘110x’) as
the geometry string:

def make_thumb (the_img)
require ‘RMagick’
size = “110x”
debugger if ENV[‘RAILS_ENV’] == ‘development’
img = Magick::Image.from_blob(the_img.img_data).first
img.change_geometry(‘110×’) {|cols, rows, i| i.resize!
(cols,rows) }

img.change_geometry(“110×”) {|cols, rows, i| i.resize!

(cols,rows) }

img.change_geometry("#{size}") {|cols, rows, i| i.resize!

(cols,rows) }
end

… but it all works OK when the size is buried within “#{size}”.

The debugger doesn’t seem to see any difference:

(rdb:1) l
[112, 121] in ./script/…/config/…/app/controllers/
images_controller.rb
112 def make_thumb (the_img)
113 require ‘RMagick’
114 size = “110x”
115 debugger if ENV[‘RAILS_ENV’] == ‘development’
=> 116 img = Magick::Image.from_blob(the_img.img_data).first
117 img.change_geometry(‘110×’) {|cols, rows, i| i.resize!
(cols,rows) }
118 # img.change_geometry(“110×”) {|cols, rows, i| i.resize!
(cols,rows) }
119 # img.change_geometry("#{size}") {|cols, rows, i| i.resize!
(cols,rows) }
120 end
121
(rdb:1) p size
“110x”
(rdb:1) p (‘110×’)
“110×”
(rdb:1) p (“110×”)
“110×”
(rdb:1) p ("#{size}")
“110x”

… and I sure don’t. Am still trying to figure out which way is up
with much of this, and would appreciate any insight as to what’s going
on here.

Thanks!

ps:
ruby 1.8.5 (2006-12-04 patchlevel 2) [i386-linux]
rails-1.2.2
GraphicsMagick 1.1.7
RMagick-1.15.2
fedora core 5


#2

On Apr 19, 2007, at 2:32 PM, joanie_abalone wrote:

size = "110x"

… but it all works OK when the size is buried within “#{size}”.
=> 116 img = Magick::Image.from_blob(the_img.img_data).first
(rdb:1) p (‘110×’)
“110×”
(rdb:1) p (“110×”)
“110×”
(rdb:1) p ("#{size}")
“110x”

I suspect you’re cut-n-pasting! Retype the literals 100x with a real
lowercase “X” rather than the little multiplication sign that seems
to be in there. It’s pretty obvious with the font on my system that
they’re different.

-Rob

RMagick-1.15.2
fedora core 5

Rob B. http://agileconsultingllc.com
removed_email_address@domain.invalid


#3

Very Good!

Here’s a geometry string pasted into vi from the rmagick page, into
‘foo’, versus keystroking the same string into ‘bar’

[pf@gezora imgr]$ cat foo
“110×”

[pf@gezora imgr]$ cat bar
“110x”

[pf@gezora imgr]$ cat foo | od -b
0000000 042 061 061 060 303 227 042 012

[pf@gezora imgr]$ cat bar | od -b
0000000 042 061 061 060 170 042 012 012

bar’s octal ‘170’ makes a good ‘x’ for the geometry string … foo’s
‘303’ … not so good.

won’t do that anymore. thanks!

On Apr 19, 11:48 am, Rob B. removed_email_address@domain.invalid