Developer Builds Browser-Based HEIC Converter That Enforces Strict File Size Limits
A developer has built a browser-based HEIC image converter using Rust compiled to WebAssembly, designed to guarantee output files stay at or below a user-specified byte ceiling rather than simply adjusting a quality slider. The tool decodes HEIC images once into a reusable RGB buffer to avoid costly repeated decoding during preview, rotation, and compression steps. For JPEG output, the converter uses a binary search over a protected quality range (minimum quality 55) to find the highest quality that fits within the target size, falling back to dimension reduction when no quality setting is sufficient. PNG output lacks a comparable quality knob, so the tool instead scales dimensions down iteratively until the file fits, then attempts small upward resizes to make better use of the remaining byte budget. The implementation treats the size target strictly in bytes internally, and tests assert the actual byte inequality rather than relying on rounded kilobyte labels.
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