Forum: Ruby on Rails invalid geometry string in change_geometry

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B8928aca5999442d49761ee1a64f9ada?d=identicon&s=25 joanie_abalone (Guest)
on 2007-04-19 20:33
(Received via mailing list)
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
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-04-19 20:49
(Received via mailing list)
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 Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
B8928aca5999442d49761ee1a64f9ada?d=identicon&s=25 joanie_abalone (Guest)
on 2007-04-19 21:28
(Received via mailing list)
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 Biedenharn <R...@AgileConsultingLLC.com>
This topic is locked and can not be replied to.