So im trying to get image cropping to work on Amazon S3, I have the following function
因此,我试图让图像裁剪在Amazon 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
This is working fine offline, all ive changed to deploy this on Heroku + S3 is "to_file" the error message im receiving is
这是正常离线工作,所有香港专业教育学院改为在Heroku + S3上部署这个是“to_file”错误消息即时接收是
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.
我有点超出深度,所以我不知道如何调试这个,任何帮助将不胜感激,我整个周末一直在摔跤。
2 个解决方案
#1
0
Try Magick::ImageList.new(self.photo.to_file.path)
instead (notice .path
in the end). Same with other image. ImageList
takes file names only:
尝试使用Magick :: ImageList.new(self.photo.to_file.path)(最后注意.path)。与其他图像相同。 ImageList仅采用文件名:
#2
-1
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.
这是一个可以轻松安装的宝石。它与S3完美配合,可以一次为您生成不同的缩略图。
Check out https://rubygems.org/gems/paperclip for more details.
有关详细信息,请查看https://rubygems.org/gems/paperclip。
#1
0
Try Magick::ImageList.new(self.photo.to_file.path)
instead (notice .path
in the end). Same with other image. ImageList
takes file names only:
尝试使用Magick :: ImageList.new(self.photo.to_file.path)(最后注意.path)。与其他图像相同。 ImageList仅采用文件名:
#2
-1
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.
这是一个可以轻松安装的宝石。它与S3完美配合,可以一次为您生成不同的缩略图。
Check out https://rubygems.org/gems/paperclip for more details.
有关详细信息,请查看https://rubygems.org/gems/paperclip。