Hi there
I have a helper method in my Rails app that uses Minimagick as a plugin.
All is fine except for the write step where I attempt to write the
resized file to another directory.
I get the error: "undefined method `to_str'' for
#<Array:0x25221e8>"
Here''s my resizing method:
def display_thumb(product_id)
# glob through images/books/thumbs dir to find thumb that matches isbn of book
p = Product.find(product_id).isbn
z = Dir["#{RAILS_ROOT}/public/images/books/#{p}.{gif,jpg,png}"]
i = MiniMagick::Image.new(z)
w = i[:width]
h = i[:height]
w = w.to_f
h = h.to_f
max_size = 60
if (w > max_size || h > max_size)
if (w > h)
h = (h*(max_size/w)).to_i
w = max_size
else
w = (w*(max_size/h)).to_i
h = max_size
end
t = z.map {|image| "books/thumbs/" + File.basename(image)}
i.resize "#{w}x#{h}"
i.write(t)
end
end
Any clues would be appreciated...as I said, all is fine until I
attempt to write the image to another directory. It''s resizing fine
until then.