A phone photo can look upright even when its stored pixels are sideways. The viewer reads an EXIF Orientation instruction and adjusts the display. That detail matters when you remove EXIF in JavaScript: deleting the instruction without transforming the pixels can change how the photograph appears.
For a browser application, one practical option is to decode the photo with its orientation applied, draw it onto a canvas and export a new image. This guide uses built-in browser APIs. It is a conversion workflow, so it does not promise identical JPEG bytes or unchanged colour rendering.
ORIENTATION FIRST, EXPORT SECOND
createImageBitmap accepts an imageOrientation option. Using "from-image" tells the decoder to use the source orientation when present. The resulting bitmap can then be drawn in the intended orientation. Avoid adding a second manual rotation unless your application deliberately handles raw, un-oriented pixels; otherwise you risk rotating the photograph twice.
Canvas export builds an image from the rendered bitmap rather than copying the original file's metadata containers. The browser may write its own technical fields, including resolution information. Describe the result as a fresh export without the source EXIF, rather than as a file containing literally zero metadata.
A SMALL JPEG EXPORT FUNCTION
async function exportCleanJpeg(file) {
const supported = ["image/jpeg", "image/png", "image/webp"];
if (!supported.includes(file.type)) {
throw new Error("Choose a JPG, PNG or WebP image.");
}
if (file.size > 10 * 1024 * 1024) {
throw new Error("Choose a file smaller than 10 MB.");
}
const bitmap = await createImageBitmap(file, {
imageOrientation: "from-image"
});
try {
if (bitmap.width * bitmap.height > 24000000) {
throw new Error("Image dimensions are too large.");
}
const canvas = document.createElement("canvas");
canvas.width = bitmap.width;
canvas.height = bitmap.height;
const ctx = canvas.getContext("2d");
if (!ctx) throw new Error("Canvas is unavailable.");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(bitmap, 0, 0);
return await new Promise((resolve, reject) => {
canvas.toBlob(blob => blob ? resolve(blob) :
reject(new Error("JPEG export failed.")), "image/jpeg", 0.92);
});
} finally {
bitmap.close();
}
}
Call the function with the File returned by a file input. The returned Blob can be downloaded with an object URL or passed to your application's next step. Revoke download object URLs when they are no longer needed. The function itself contains no upload request.
WHAT CHANGES DURING THIS PROCESS?
JPEG output is recompressed. The quality parameter is an encoder preference, not a universal score or a promised reduction in file size. PNG transparency becomes white in this example because JPEG cannot store an alpha channel. Animated input is outside this workflow's scope; do not describe a rendered still as a preserved animation.
A byte-size limit also cannot fully protect against a small compressed file with enormous dimensions. The dimension check above happens after decoding. For hostile uploads, add earlier header validation, resource limits and server-side validation if the result is later uploaded. MIME text supplied by a file picker is not a security boundary.
VERIFY THE ACTUAL DOWNLOAD
Build a small fixture collection with portrait orientation, mirrored orientation, GPS, XMP and ordinary landscape images. Open each exported download in a separate viewer, inspect its metadata with an independent tool and compare important colours and transparency. Check errors on the browsers you actually support.
If you need encoded-image preservation, choose a format-aware container editor instead of canvas and handle orientation deliberately. For occasional cleaning, the StripAITags image cleaner at https://stripaitags.com/ provides a browser interface. Review its detection report and keep the original until the export has been checked.
Further reading
ImageBitmap decoding and orientation: https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap
Canvas Blob export: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob
ImageBitmap lifecycle: https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap
Technical Guides · 03 Nov 2026
Remove EXIF in JavaScript: A Browser Workflow That Keeps Photos Upright
Build a dependency-free browser export that handles EXIF orientation before creating a fresh image. Understand quality changes and verify the downloaded file.

ADVERTISEMENT
