unjs / ipx

🖼️ High performance, secure and easy-to-use image optimizer.
MIT License
1.54k stars 61 forks source link

Change file extension when converting format #54

Closed Razunter closed 2 years ago

Razunter commented 2 years ago

Currently, file extension stays the same on conversion to a different format. This is a bad behavior and should be fixed.

pi0 commented 2 years ago

Hi @Razunter. What do you mean by file extension? I believe handler sends the right meme and we are not sending any other header about file name or extension.

Razunter commented 2 years ago

Hm… I've meant generation urls always end in the original file extension, and it causes confusion: avif-wepb etc. still end up with urls looking like they are wrong extension. Like in the docs: http://localhost:3000/embed,f_webp,s_200x200/static/buffalo.png. It's webp, but it looks like png since url ends with png.

pi0 commented 2 years ago

I can understand DX issues but we cannot change the last part as it has to directly map to the source id. Without the extension, we don't know what is an original file path. I'm closing this issue as cannot think of an easy possible solution but please ping to reopen if you have an idea without changing signature and dropping source extension.

toto6038 commented 4 months ago

Though it may not be a clever solution, how about appending the converted file extension so that we can keep both the mapping relation while still having the browser to pick up the right file extension.

Example: Original file @/static/buffalo.png becomes /f_webp/static/buffalo.png.webp