html
html copied to clipboard
canvas.toDataUrl / toBlob should let you specify lossless compression for webp
There is no way to specify lossless compression for the webp codec. Chrome seems to treat a quality of 1 as lossless (which is not really correct). There were discussions about adding a third parameter specifying a lossless flag or adding a special mimetype for losslesswebp. However, the only logical thing in my opinion is to allow to pass an object as second parameter with the encoderOptions (funny enough MDN already calls the second parameter "encoderOptions" which would suggest an object).
This solution would allow for more specific encoder options as well. webp alone has tons of it. Options that are not supported by the browser could simply be ignored.
cc @whatwg/canvas
Yeah, a dictionary here is probably a good idea.
Bump. libwebp which is included in every browser's source code supports lossless encoding out of the box and the files created are much smaller than PNGs. Only the flag needs to be passed. When calling canvas.toDataUrl / toBlob allowing passing an object with options that can be interpreted individually by every codec instead of a single float seems like a natural step forward