Imagemagick和mini_magick gem都已安装,但我上传pdf时无法保存模型。
尝试创建模型的新实例时,出现以下错误:
Pdf Failed to manipulate with MiniMagick, maybe it is not an image?
我在这里做错了什么?我的意图是使用以下所示的解决方案:http://afreshcup.com/home/2012/9/27/thumbnailing-pdfs-with-minimagick.html
我的上传者:
class PrivatePdfUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def default_url
"/images/fallback/" + [version_name, "default.png"].compact.join('_')
end
version :web_thumb do
process :thumbnail_pdf
end
def thumbnail_pdf
manipulate! do |img|
img.format("png", 1)
img.resize("150x150")
img = yield(img) if block_given?
img
end
end
end
答案 0 :(得分:3)
你安装了ghostscript吗?
brew install ghostscript