nerdgeschoss / shimmer

Shimmer is a collection of Rails extensions that bring advanced UI features into your app and make your life easier as a developer.
https://nerdgeschoss.de
MIT License
5 stars 1 forks source link

Make image resizing Vips compatible #95

Closed danieldiekmeier closed 1 month ago

danieldiekmeier commented 1 month ago

Until now, we used the ImageMagick exclusive "200x300>" syntax, so any project that uses shimmer is forced to also use ImageMagick. Since Vips is much much faster, we want to switch. But first, we have to adjust Shimmer to be compatible.

This was not too hard since we mostly don't leak the ImageMagick-style strings to the outside. We persist them in the generated id (which is used in the URLs). The message_verifier.generate method can encode arbitrary data, so we don't use these strings anymore from now on. Instead, we directly save [width, height] tuples.

BUT we don't want all our URLs to change at once: This would break any hotlinked URLs (maybe not a big deal), but also invalidate all our caches. So we grandfather in old URLs for now. Maybe we can remove them in 10 years.

Since we're switching to the ImageProcessing-style resize_to_limit: [width, height] format, this new version should in theory be compatible with BOTH ImageMagick AND Vips.

Some apps, like Copa, use FileProxy directly and pass a ImageMagick-style string. These need to be fixed before we can upgrade Shimmer there. https://github.com/search?q=org%3Anerdgeschoss+FileProxy&type=code

(This PR also includes a little overhaul to CI and the Rails test app.)

Bonus: Fixes #59. Rubocop works for all three Ruby versions in the matrix now.