image_processing: #saver should ignore unsupported options

So I’m using the saver method to set the quality level of my JPEGs in my Shrine app.

ImageProcessing::Vips
  .source(image)
  .autorot
  .resize_to_fit, 1024, 1024)
  .saver(Q: 85, interlace: true)
  .sharpen(sigma: 1.5, x1: 1.5, y2: 15, y3: 15, m1: 0.4, m2: 0.8)
  .call

The app itself is agnostic about supported image file types. You can upload a JPEG, PNG, or GIF. But when I run a PNG or GIF through my version processor in Shrine, I get this error:

Vips::Error: unable to call VipsForeignSavePngFile: unknown option Q

It would be better to discard unsupported options when #saver arguments get passed along to #vips_pngsave, etc.

That way, it would just do the right thing with each respective image format – without any errors.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

FYI… after more research, I discovered that all three image formats (JPG, PNG, GIF) technically support interlacing.

minimagick (and imagemagick) supports interlacing all three formats. libvips supports interlacing on JPEGs and PNGs (but not GIFs – since libvips can’t write GIFs).