HTML Canvas Strips All Image Metadata, Including EXIF and Orientation Flags
When an image is processed through an HTML canvas element, all embedded metadata — including GPS coordinates, camera details, ICC color profiles, and EXIF orientation flags — is permanently discarded, leaving only raw pixel data. This behavior can be a privacy advantage, as browser-based tools that compress or resize images automatically strip identifying information without uploading files to a server. However, the silent loss of orientation flags causes a common bug: photos taken on phones are stored sideways and rely on an EXIF flag to display correctly, so after a canvas round-trip the output appears permanently rotated. Developers can fix this since around 2020 by using the createImageBitmap API with the imageOrientation: 'from-image' option, which bakes the correct rotation into the pixels before drawing to the canvas. The bug is especially tricky to catch because the browser correctly orients the original preview image, making the problem invisible until the processed file is downloaded.
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