views:

17

answers:

1

Hey guys,

So im trying to get image cropping to work on Amazon S3, I have the following function

def update_attributes(att)
  scaled_img = Magick::ImageList.new(self.photo.to_file)
  orig_img = Magick::ImageList.new(self.photo.to_file(:original))
  scale = orig_img.columns.to_f / scaled_img.columns

  args = [ att[:x1], att[:y1], att[:width], att[:height] ]
  args = args.collect { |a| a.to_i * scale }

  orig_img.crop!(*args)
  orig_img.write(self.photo.to_file(:original))

  self.photo.reprocess!
  self.save

  super(att)
end

This is working fine offline, all ive changed to deploy this on Heroku + S3 is "to_file" the error message im receiving is

undefined method `columns' for Magick::ImageList

Im a little bit out of depth so im not sure how to debug this, any help would be greatly appreciated, I have been wrestling with this all weekend.

A: 

If you want to accept image uploads (or just store images) and resize them I can highly recommend using paperclip.

It's a gem you can easily install. It works perfectly with S3 and can generate different thumbnails for you in one go.

Check out https://rubygems.org/gems/paperclip for more details.

Ariejan