imgproxy icon indicating copy to clipboard operation
imgproxy copied to clipboard

ENFORCE_WEBP & SKIP_PROCESSING_FORMATS which should happen?

Open legopin opened this issue 3 years ago • 4 comments

I'm not sure if this is intended behavior of how these two settings should interact

Summary Table Assume

  • IMGPROXY_ENFORCE_WEBP=true
  • gif source
settings Accept Header Resulting Format
no webp gif
webp webp
skip=gif no webp gif
skip=gif webp gif

Env

imgproxy:v3.0.0 docker image

env variables used

- IMGPROXY_MAX_SRC_RESOLUTION=50
- IMGPROXY_MAX_ANIMATION_FRAMES=50
- IMGPROXY_ENABLE_WEBP_DETECTION=true
- IMGPROXY_ENFORCE_WEBP=true
- IMGPROXY_SKIP_PROCESSING_FORMATS=gif

Expected

Given a gif source image and the env settings above, when requesting with header Accept: image/webp,*/*;q=0.8, I would expect the resulting image format to be webp. imgproxy url : localhost:8080/insecure/w:480/plain/local://image/lego_dance.gif

For enforce webp I assumed the resulting image format will be set to webp

enables WebP support detection and enforces WebP usage. If the browser supports WebP, it will be used as resulting format even if another extension is specified in the imgproxy URL.

For skip processing I assumed since the source (gif) and resulting (webp) are different, image will still be processed

Processing can be skipped only when the requested format is the same as the source format.

https://docs.imgproxy.net/configuration?id=skip-processing

Actual Behavior

When using Accept webp header, the resulting image is still unprocessed gif

legopin avatar Nov 26 '21 10:11 legopin

Hey @legopin! This is intended behavior. Maybe the docs aren't clear enough 🤔

The main purpose of this feature is to skip heavy lifting like processing of GIFs. And I believe this should be controlled by the developer. So if you added a format to a skip-list, images in this format won't be processed unless you specify another resulting format right in the URL.

DarthSim avatar Nov 26 '21 13:11 DarthSim

I see, maybe it will help to add a note in documentation next to skip processing explicitly stating that ENFORCE_WEBP will not activate for that source image format when it is skipped

I wonder if there is a better way to achieve what we are after, we currently wrote a proxy service in front of imgproxy to implement this: Allow gif -> webp conversion while stopping gif -> gif processing

  1. Accept header does not not contain webp and source img url ends with gif, we fetch the original image from Google Cloud Storage directly
  2. All other requests pass through to imgproxy

This is due to gif resizing often increased the size of the gifs and being much slower, but the webp conversion is effective. We are only keeping gif output as compatibility to older clients

legopin avatar Nov 30 '21 02:11 legopin

Did you try v3.0.0? It uses the new vips' method for saving GIFs which is much faster and generates better results

DarthSim avatar Nov 30 '21 07:11 DarthSim

Thanks for the suggestion, I tried to use v3 and indeed it's a lot better both in terms of result size and performance.

I'll leave the issue open for now in case we want to work on the documentation side, but my use case has been solved. Thank you again for maintaining this wonderful image library

legopin avatar Dec 08 '21 10:12 legopin