Why Browser AVIF Converters Inflate File Size and How Binary Search with PNG-8 Fixes It

Developers building client-side image converters with canvas.toBlob() often find that converting a small AVIF file to JPG or PNG produces a much larger output. AVIF uses AV1 compression, which is far more space-efficient than JPEG or uncompressed PNG, so re-encoding the decoded pixels in a legacy format expands the data considerably. A 60 KB AVIF photo can become roughly 160 KB as a JPG or over 280 KB as a PNG, which leads users to assume the converter is malfunctioning. The author describes a two-part TypeScript solution that uses a binary search over quality settings and switches to PNG-8 palette output to curb this bloat. The approach runs entirely in the browser, so no images are uploaded to a server.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in