因此,我尝试让图像裁剪在亚马逊S3上工作,我有以下功能
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这在脱机状态下工作得很好,所有我都更改为在Heroku + S3上部署它是"to_file“,im收到的错误消息是
undefined method `columns' for Magick::ImageList我有点不深入,所以我不确定如何调试这个,任何帮助都会非常感谢,我整个周末都在努力解决这个问题。
发布于 2010-12-04 09:31:13
请尝试Magick::ImageList.new(self.photo.to_file.path) (请注意最后的.path )。其他图像也是如此。ImageList只接受文件名:
http://www.imagemagick.org/RMagick/doc/ilist.html#new
发布于 2010-10-25 21:02:48
如果你想接受图片上传(或者只是存储图片)并调整它们的大小,我强烈推荐使用paperclip。
这是一个您可以轻松安装的gem。它与S3完美配合,可以一次生成不同的缩略图。
有关更多详细信息,请查看https://rubygems.org/gems/paperclip。
https://stackoverflow.com/questions/4014202
复制相似问题