jpegrecompress worker: `jpeg-recompress` not found;

随声附和 提交于 2019-12-13 03:00:42

问题


I recently installed the paperclip-optimizer gem in my Rails 4 app on Heroku. Whenever I attempt to save an uploaded image attachment, I get the following error: jpegrecompress worker: 'jpeg-recompress' not found; in my logs from Heroku, but not on localhost.

I'm not sure what I'm missing. I can't seem to find a single StackOverflow post, blog post, or other resource on this problem.

Here is my 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)
    }
}

In my photo.rb model I have:

has_attached_file :image, styles: { large: "600x600>", medium: "300x300>", thumb: "100x100>" }, default_url: "", processors: [:thumbnail, :paperclip_optimizer]

In my .buildpacks file for Heroku I have:

https://github.com/ddollar/heroku-buildpack-multi.git
https://github.com/heroku/heroku-buildpack-ruby.git
https://github.com/bobbus/image-optim-buildpack.git

I added the Ruby buildpack to solve this problem I was having earlier, but now it seems as though the multi and the image-optim buildpacks aren't loading.

Thanks!


回答1:


After much head banging and keyboard bashing, I figured out how to solve the problem. In my case, I'm running a Rails 4.0 app on the Cedar-14 stack running on the Puma webserver, so these instructions may or may not be of use to you if you're configuration is different.

  1. I followed the steps on this Heroku Dev Center article on adding multiple buildpacks to an app, which is now supported by Heroku. In my case, I have the following buildpacks added for my app:

    === staging-app Buildpack URLs
    1. https://github.com/bobbus/image-optim-buildpack.git
    2. https://github.com/heroku/heroku-buildpack-ruby.git
    

    The order is critical. The last buildpack on the list is the first one to be loaded. In my case, I need the Ruby buildpack so that the bundle command in my Procfile is recognized. See this question for more on that issue.

  2. Do NOT use the Heroku-Buildpack-Multi. From what I understand, this is the old way to support multiple buildpacks. Adding this will cause your pushes to be rejected.

  3. In my Gemfile, I needed to include the image_optim and image_optim_pack gems. These gems make the appropriate binaries available on OS X and Linux environments, from what I understand. It is very important to place these gems before paperclip-optimizer in the Gemfile, like so

    gem 'paperclip', '~> 4.1'
    group :production do
        # Needs to be placed before paperclip-optimizer
        gem 'image_optim'
        gem 'image_optim_pack'
    end
    gem 'paperclip-optimizer'
    
  4. Configure your paperclip-optimizer settings as you see fit and push to production.

Hopefully this helps someone in my situation.



来源:https://stackoverflow.com/questions/32467247/jpegrecompress-worker-jpeg-recompress-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!