jamsinclair / jSquash

Browser & Web Worker focussed wasm bundles derived from the Squoosh App.
Apache License 2.0
222 stars 14 forks source link

Possibility of converting an image to AVIF without losing quality #29

Closed patratel closed 1 year ago

patratel commented 1 year ago

Hi,

I was wondering if there is any way of converting an image without losing quality. I've tried tweaking with the encode options to no avail(mostly the cqLevel). It's mostly visible when i convert low rez images, and less so when using high rez images. These are the current options I'm now using

cqLevel: 10, cqAlphaLevel: -1, denoiseLevel: 0, tileColsLog2: 0, tileRowsLog2: 0, speed: 6, subsample: 1, chromaDeltaQ: false, sharpness: 0,

jamsinclair commented 1 year ago

Good question @patratel . Sounds like you want lossless encoding. Your settings look like they're almost there.

Based on the Squoosh code – you'll need the following values to trigger lossless mode

That should activate this branch of the code and hopefully give you lossless conversion 🤞 https://github.com/jamsinclair/jSquash/blob/f662d8c9e1599129fd2108cbe22aff7a713958fb/packages/avif/codec/enc/avif_enc.cpp#L61-L63

patratel commented 1 year ago

Hey thank you for your answer. This did the trick!

jamsinclair commented 1 year ago

Great to hear! I'll mark this as resolved and close then 👍