When I use Active Storage, and when someone upload a .webp image, and when I run file.attach(io: webp_file, filename: 'file.webp') it works, and then ActiveStorage automatically run a job ActiveStorage::AnalyzeJob
But this job raises :
MiniMagick::Error (`identify -format %[orientation] /tmp/ActiveStorage-114989-20180905-4-wak8ob.webp[0]` failed with error:
identify-im6.q16: delegate failed `'dwebp' -pam '%i' -o '%o'' @ error/delegate.c/InvokeDelegate/1919.
identify-im6.q16: unable to open file `/tmp/magick-1400SWBHj-p67HrV': No such file or directory @ error/constitute.c/ReadImage/544.
Although I am on Heroku-18, and so there is a lib called "libwepb6" (https://devcenter.heroku.com/articles/stack-packages) 🤔
Do I have to create a Heroku buildpack?
Had the same problem. Here's the step by step:
1 - Add this to development.rb and production.rb to force rails to accept WEBP.
config.active_storage.variable_content_types = %w(
  image/png
  image/gif
  image/jpg
  image/jpeg
  image/webp
  image/vnd.adobe.photoshop
  image/vnd.microsoft.icon
)
2 - Add this buildpack to your app on heroku, making sure it's the first pack. It allows you to install ubuntu packages that are not already preinstalled.
3 - Navigate to the root of your app (where your Gemfile is) and run the commands below to create a file named AptFile, and add the webppackage to it.
touch Aptfile
echo "webp" >> Aptfile 
4 - Redeploy your app.
Heroku will now install the missing webp package that imagemagick needs to handle webp images.
Edit: Step 1 is not necessary if you are on Rails 6.1 or later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With