h2non / imaginary

Fast, simple, scalable, Docker-ready HTTP microservice for high-level image processing

Home Page:https://fly.io/docs/app-guides/run-a-global-image-service/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Proposal] use "accept" header to auto-convert formats

zenyui opened this issue · comments

Hello @h2non! Thanks so much for writing Imaginary! I'm using Imaginary for loading front-end images with Next.js's image optimizer, and it's working great.

One feature I'd like to port over from Next.js's default image processor is the ability for the server to dynamically pick the output format for images based on the accept header (docs). For example, in Chrome, Next.js sends the following header when you use an <img> tag:

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

By default, you can configure Next.js to "prefer" certain formats, like webp, and the server will automatically convert the output image to the first preferred format the browser supports. You can find those docs here.

Given Imaginary already supports a type argument for converting the output format, I imagine this would be fairly simple to implement. I'm happy to open a PR to do so, but wanted to gauge your interest first.

now i see you have this feature already via type=auto! I'll experiment with that and open a new issue if needed. Thanks!