lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.33k stars 1.3k forks source link

Metadata for lossy/lossless WebP #2461

Open thatsmydoing opened 3 years ago

thatsmydoing commented 3 years ago

Could there be metadata to tell whether an input webp (or heif/avif) image is lossy or lossless? The context is we would like to preserve the lossiness when transforming images. Not just for webp -> webp but when getting an input webp, figuring out whether we should convert it to JPEG or PNG depending if it's lossy or not.

Maybe something like a lossless boolean as part of the input metadata?

lovell commented 3 years ago

Hi, this would need exposing in libvips first, plus there's complexity around animated WebP images where each frame can be either lossy or lossless.

jcupitt commented 3 years ago

webp also allows different parts of the same image to be lossy or lossless -- it's common to have a lossless alpha and a lossy RGB, for example.

thany commented 3 years ago

webp also allows different parts of the same image to be lossy or lossless -- it's common to have a lossless alpha and a lossy RGB, for example.

If lossiness is going to be a simple boolean: if any part of an image is lossy, the image as a whole is effectively lossy. In other words, you shouldn't consider a image that is partly lossless, to be entirely lossless.