我最近在Heroku的Rails 4应用程序中安装了paperclip-optimizer gem。每当我尝试保存上传的图像附件时,我都会收到以下错误:来自Heroku的日志中的jpegrecompress worker: 'jpeg-recompress' not found;
,但不会出现在localhost上。
我不确定我错过了什么。我似乎无法找到关于此问题的单个StackOverflow帖子,博客文章或其他资源。
这是我的config/initializers/paperclip_optimizer.rb
:
Paperclip::PaperclipOptimizer.default_options = {
skip_missing_workers: true,
advpng: false,
gifsicle: false,
jhead: false,
jpegoptim: false,
jpegrecompress: true,
jpegtran: false,
optipng: false,
pngcrush: false,
pngout: false,
pngquant: true,
svgo: false,
nice: 10, # Nice level (defaults to 10)
threads: 1, # Number of threads or disable (defaults to number of processors)
verbose: false, # Verbose output (defaults to false)
pack: nil, # Require image_optim_pack or disable it, by default image_optim_pack will be used if available,
allow_lossy: true, # Allow lossy workers and optimizations (defaults to false)
jpegrecompress: {
quality: 2 # JPEG quality preset: 0 - low, 1 - medium, 2 - high, 3 - veryhigh (defaults to 3)
},
pngquant: {
quality: 100..100, # min..max - don't save below min, use less colors below max (both in range 0..100; in yaml - !ruby/range 0..100) (defaults to 100..100)
speed: 3 # speed/quality trade-off: 1 - slow, 3 - default, 11 - fast & rough (defaults to 3)
}
}
在photo.rb
模型中,我有:
has_attached_file :image, styles: { large: "600x600>", medium: "300x300>", thumb: "100x100>" }, default_url: "", processors: [:thumbnail, :paperclip_optimizer]
在Heroku的.buildpacks
文件中,我有:
https://github.com/ddollar/heroku-buildpack-multi.git
https://github.com/heroku/heroku-buildpack-ruby.git
https://github.com/bobbus/image-optim-buildpack.git
我添加了Ruby buildpack来解决this problem我之前遇到的问题,但现在似乎没有加载multi和image-optim构建包。
谢谢!