Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider: Switching from ImageMagick to Vips #20269

Open
matthewford opened this issue Nov 9, 2022 · 4 comments · May be fixed by #30090
Open

Consider: Switching from ImageMagick to Vips #20269

matthewford opened this issue Nov 9, 2022 · 4 comments · May be fixed by #30090
Labels
suggestion Feature suggestion

Comments

@matthewford
Copy link
Contributor

matthewford commented Nov 9, 2022

Pitch

In Rails 7, the default image process is now vips rails/rails#42744

It's faster and uses less memory, ruby-vips can also fall back to ImageMagick if needed (although kt-paperclip doesn't use ruby-vips which would require switching to ActiveStorage).

The is a guide on how to migrate to vips can be found here: https://gist.github.com/brenogazzola/a4369965a1da426d50f11d080fe2e563

On Heroku either a custom apt-file or buildpack would be needed, https://elements.heroku.com/buildpacks/brandoncc/heroku-buildpack-vips

As the image processor is using kt-paperclip you would need to use this fork for the image processor https://github.com/tsu-social/paperclip-vips

It might also be worth switching to ActiveStorage, but I opened another issue for that.

Motivation

All servers:

@matthewford matthewford added the suggestion Feature suggestion label Nov 9, 2022
@matthewford matthewford changed the title Consider switching from ImageMagick to Vips Consider: Switching from ImageMagick to Vips Nov 9, 2022
@matthewford
Copy link
Contributor Author

If this is done, then switching will be simpler: #7414

@renchap
Copy link
Sponsor Member

renchap commented Nov 11, 2022

Having switched from imagemagick to vips in a major project, I can confirm all the advantages @matthewford described above.

The security aspect is major and the speed/memory boosts are impresive.

A potential drawback here is that libvips is often quite outdated on many linux distributions, so this could be a problem for people self-hosting their instance without a pre-build docker image. This is not a blocker, but we will need to force a minimal libvips version and probably add some documentation on how to install it using third-party packages on some old-but-widly-used distros.

Also https://github.com/janko/image_processing is a very nice gem to abstract image manipulation (with imagemagick and vips support), this should probably be used if there is any work done on image processing.

@nemobis
Copy link
Contributor

nemobis commented Jun 1, 2023

For information on broader usage it's also possible to look at the Wikimedia wikis' experience with VipsScaler. See for example VipsScaler implementation by volunteer developer improves image handling on Wikimedia sites (2013).

@renchap
Copy link
Sponsor Member

renchap commented Jun 1, 2023

FYI switching to Vips is in the roadmap. No date yet, but we want to rework the whole media storage system and it will most definitely be part of it.

@renchap renchap linked a pull request Apr 26, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Feature suggestion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants