How the Client-Side Image Compressor works
How it works
The compressor decodes the selected file into an in-memory HTMLImageElement, then lets you choose an output format (lossy JPG, lossy WebP, or lossless PNG), a quality value from 0.1 to 1, and a target width. The height is recomputed automatically to preserve the original aspect ratio. The image is then drawn onto a 2D canvas with drawImage. For JPEG output the tool paints a solid white background first, because the JPEG format cannot store an alpha channel; WebP and PNG keep transparency. Finally, canvas.toBlob encodes the result with the chosen format and quality.
The target width is capped at the source image's natural width, so the tool never upscales — enlarging would only interpolate pixels without adding detail. The quality slider drives the encoder for lossy formats; for PNG it is intentionally ignored because PNG compresses without discarding data. Every step runs inside the browser, so the file is processed locally and no image data is uploaded.
Use cases
People use this tool to shrink photos before emailing them, uploading them to a website, or posting them to social platforms; to reduce screenshots before attaching them to tickets and documentation; and to fit images under strict file-size limits without installing desktop software.
Troubleshooting
If a transparent PNG becomes opaque, check the format — JPG output always fills transparency with white because it cannot hold an alpha channel; switch to PNG or WebP to keep transparency. If the quality slider seems to do nothing, you are likely encoding to PNG, which is lossless by design. Very large images can be slow or fail, because browsers cap canvas dimensions and decoding a huge file consumes a lot of memory; reduce the target width or start from a smaller source. If the page reports that Canvas is unavailable, the current environment lacks 2D canvas support and compression cannot run there. If the output looks rotated or its dimensions appear swapped, the source photo is carrying an EXIF orientation tag — phone cameras store rotation there instead of rotating pixels. Modern browsers honor that tag when decoding, but a pipeline or viewer that skips it can produce a sideways result, so normalize the orientation in the source file before compressing.