我正在尝试使用Heroku rails服务器上的ImageMagick(rmagick gem)裁剪图像。这是我的代码:
class PhotoUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
#include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def crop
if model.crop_x.present?
manipulate! do |img|
x = model.crop_x.to_i
y = model.crop_y.to_i
w = model.crop_w.to_i
h = model.crop_h.to_i
img.crop!(x, y, w, h)
puts "officially cropped!"
end
end
end
version :standard do
process :crop
resize_to_limit(2000, 2000)
end
end
这是它一直向我投掷的错误:
2016-03-03T12:18:22.236892 + 00:00 app [web.1]:已完成500内部 服务器错误296ms 2016-03-03T12:18:22.243033 + 00:00 app [web.1]: 2016-03-03T12:18:22.243040 + 00:00 app [web.1]:ArgumentError(无图像 在此图片列表中):2016-03-03T12:18:22.243041 + 00:00 app [web.1]:
app / uploaders / photo_uploader.rb:21:in,crow' 2016-03-03T12:18:22.243046 + 00:00 app [web.1]:
有什么想法吗?
答案 0 :(得分:0)
您需要包含ImageMagick buildpack。没有它,Heroku不包含rmagick所需的文件。 https://github.com/ello/heroku-buildpack-imagemagick
这还需要您运行多个buildpack。 https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app