Converting WebP to JPG in a Chrome Extension Using OffscreenCanvas
Browsers increasingly save images as WebP or AVIF, and simply renaming the file to .jpg does not change the actual format, so many upload forms and editors reject it. The developer of PixLasso, a Chrome and Edge extension that bundles page images into a ZIP, built an on-device JPG conversion feature that never uploads data. Because Manifest V3 service workers lack URL.createObjectURL and cannot decode SVG reliably, the conversion runs in a hidden offscreen document that the worker opens on demand. The post explains the decoding path, which tries createImageBitmap first and falls back to an image element with a timeout for SVGs, along with canvas drawing and memory handling. It also covers canvas size limits and detecting the true image format from file bytes rather than trusting filenames or headers.
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