JPEG libraries for Ruby
Ruby has no pure-Ruby JPEG codec in common use; both main options wrap a C library:
- ruby-vips binds libvips through FFI. It’s several times faster than ImageMagick and uses much less memory, because it streams images and decodes JPEGs at reduced size for thumbnails. Rails’ Active Storage uses it by default (
image_processinggem). - MiniMagick runs ImageMagick’s
magickcommand. Easy to use, every ImageMagick option is available, but each operation starts a process and large images use a lot of memory.
For Exif only, exifr (MIT) reads JPEG and TIFF Exif in pure Ruby.
- MiniMagick MiniMagick is a Ruby wrapper of the ImageMagick command line. How to resize and auto-orient JPEG photos, set quality and progressive mode, read Exif.
- ruby-vips ruby-vips is the Ruby binding of libvips. How to make JPEG thumbnails fast, auto-rotate photos, save with quality, progressive and subsampling options.