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

Support webP transform with the image proxy transform API #2508

Open
dohomi opened this issue Feb 2, 2024 · 7 comments
Open

Support webP transform with the image proxy transform API #2508

dohomi opened this issue Feb 2, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@dohomi
Copy link
Contributor

dohomi commented Feb 2, 2024

Is your feature request related to a problem? Please describe.
Returning webP for JPG, PNG and other file format would significantly reduce the file size and accelerate the CDN API by lowering the transferred data size.

Describe the solution you'd like
It would be great if images be optimised when q=70 or a different query param is been used.

Additional context
WebP is supported by the 96% of browsers based on
https://caniuse.com/webp

@dohomi dohomi added the enhancement New feature or request label Feb 2, 2024
@dbarrosop
Copy link
Contributor

Automatic conversion between different formats is something we probably don't want to do but we could add a ?f=webp or similar to request the output format.

@jovermier
Copy link

I have been investigating this exact idea @dohomi over the past week. Thank you for creating this post. I would also like the ability to request a specific file type from nhost. It looks like nhost uses sharp package which already supports this feature. The search param f=webp would be a great option.

I was also considering doing the conversion to webp when the image is uploaded so storage only has webp images in it thus cutting down on the storage usage and request image transformation execute time.

@dbarrosop
Copy link
Contributor

We don't use sharp (wrong programming language :P) but it doesn't matter, the library we use is also built on top of libvips and has support for this. If someone wants to contribute this feature that'd be great, happy to help guiding. Otherwise we will get to this when we can.

@dohomi
Copy link
Contributor Author

dohomi commented Feb 7, 2024

I guess the best would be something like a ?o=1 (optimise=true) and based on the supported request header the image proxy would return WebP, AVIF or any other image format supported by the browser.

@dbarrosop
Copy link
Contributor

Optimize would mean different things for different people so I think being explicit is the best path forward. Also, the backend has no access to browser information so it'd be impossible to know what's supported and what's not.

@jovermier
Copy link

To clarify @dohomi, are you suggesting that if ?o=1 is present then the server should automatically convert the image to the most ideal output based on the request headers?

I grabbed this request header example from my browser:

Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8

@dohomi
Copy link
Contributor Author

dohomi commented Feb 8, 2024

@jovermier yes I think any path, either o=>optimise or c=>compress would convert the image in following order:
AVIF, WebP or no manipulation based on Accept header.

I would assume that the image proxy should have access to the browser Accept headers but @dbarrosop knows it probably better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants