Image upload looks simple — until the edge cases start showing up.
I recently published a small npm package called browser-image-guard. It came out of a problem I kept running into while building image upload flows.

At first, image upload looks simple: pick a file, compress it, send it to the backend. But then the edge cases start showing up. Some files have fake MIME types. iPhone users upload HEIC images. EXIF and GPS metadata can stay attached. Compression can fail inside a Web Worker. Older mobile browsers can get stuck on a loading state. Strict CSP rules can break the worker completely.
I had already built a reliable pipeline for this inside one of my projects, so I extracted it into a reusable package instead of maintaining the same logic in two places.
It handles real file type detection using magic bytes, HEIC/HEIF conversion, EXIF and GPS metadata removal, resize and compression, orientation fixes, worker fallback, hard file size limits, and filename sanitization.
The API is intentionally simple: processImage(file). It returns a clean, compressed JPEG ready to upload, or throws a typed error that can be mapped to the UI.
Original publication (external website)