Install latest libvips for image_processing on Heroku

kinopyo avatar

kinopyo

Rails 7 uses libvips instead of ImageMagick as the default variant processor for Active Storage. Heroku doesn't ship with libvips by default, so this post shows how to install it on Heroku.

Make sure you have followed the official upgrade guide to update your application code. The most important setting is to make sure your config.active_storage.variant_processor like below:

Rails.application.config.active_storage.variant_processor = :vips

Install latest libvips

Run the commands below to add two new buildpacks:

$ heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
$ heroku buildpacks:add --index 2 https://github.com/brandoncc/heroku-buildpack-vips

github.com/heroku/heroku-buildpack-apt
And then add this new file to the root directory of your app:

libglib2.0-0
libglib2.0-dev
libpoppler-glib8

Deploy and Verify

Git add the files and deploy to Heroku. You can verify the result by running this command:

$ heroku run vips -v
vips-8.12.1-Wed Nov 24 15:41:04 UTC 2021

Note that ActiveStorage/image_processing requires libvips 8.6+, which should be no problem if you use brandoncc's buildpack.

I've only tested this on Heroku-18 stack.

References

kinopyo avatar
Written By

kinopyo

Indoor enthusiast, web developer, and former hardcore RTS gamer. #parenting
Published in Rails
Enjoyed the post?

Clap to support the author, help others find it, and make your opinion count.