unknown said:
you are running the requires and includes at instance, not class level
etc.
After Much more Googleing for working code samples.
I notice that they All had the "require 'RMagick'" under the 'def' line.
This put me back to the error:
----
undefined method `columns' for #<Array:0xb791c810>
----
I have long forgotten why I removed the '.first' from the:
pic = Magick::Image.read(location + image).first
line, so I replaced it.
NOW things started giving me errors I could understand!!!
As the latest sample was far more eloquent than the original I was
trying to use, I substuted it for some of the code that wasn't working,
beacuse I missed something from the original code.
This is the result:
def make_thumb(location, image, thumb)
#require 'rubygems'
#require_gem 'RMagick'
#include Magick
require 'RMagick'
pic = Magick::Image.read(location + image).first
#imgwidth = pic.columns
#imgheight = pic.rows
#imgratio = imgwidth.to_f / imgheight.to_f
#imgratio > aspectratio ? scaleratio = 64 / imgwidth : scaleratio =
64 / imgheight
#thumb = pic.resize(scaleratio)
pic.change_geometry!('64x64') { |cols, rows, img|
pic.resize!(cols, rows)}
white_bg = Magick::Image.new(64, 64)
pic = white_bg.composite(pic, Magick::CenterGravity,
Magick::OverCompositeOp)
pic.write(location + thumb)
end
or more cleaned-up as:
def make_thumb(location, image, thumb)
require 'RMagick'
pic = Magick::Image.read(location + image).first
pic.change_geometry!('64x64') { |cols, rows, img|
pic.resize!(cols, rows)}
white_bg = Magick::Image.new(64, 64)
pic = white_bg.composite(pic, Magick::CenterGravity,
Magick::OverCompositeOp)
pic.write(location + thumb)
end
This code works flawlessly!
Unfortunatly, My original attempts to fix the original error were,
misguided and caused more errors than could probably be debugged
remotly.
Much thanks for conferming that RMagick was installed and working
properly.
Lance F. Squire