How-To & Life · Guide · Audio, Video & Voice
How to compress images
Reduce image file sizes by finding quality sweet spots and switching to WebP. Free, in-browser tips for batch compression and EXIF stripping instantly.
A 4MB hero image on your landing page is the fastest way to lose mobile visitors. Google’s own data shows bounce rate climbing sharply once page weight crosses 2MB on 3G — and an unoptimized iPhone photo alone often weighs more than that. The fix is image compression, which sounds simple but hides real tradeoffs: lossy versus lossless, JPEG quality sliders, WebP adoption, PNG optimization, EXIF stripping, and the difference between “looks fine” and “ships fast.” This guide covers how each compression mode actually works, the target file sizes for different page contexts, why mobile and desktop need different settings, and the small details that separate professional compression from the default export.
Advertisement
Lossy vs lossless
Lossy compression discards information the human eye is unlikely to notice — subtle color gradations, high-frequency details, imperceptible hues — to achieve dramatic size reductions. JPEG, WebP (lossy mode), and AVIF are lossy. A typical 12MP photo drops from ~10MB raw to 1–3MB at high quality, 200–500KB at mid quality.
Lossless compression keeps every pixel intact; it just encodes them more efficiently. PNG, WebP (lossless mode), TIFF, and FLIF are lossless. Size reductions are smaller — typically 10–40% — but the output is pixel-identical to the input. Use lossless for screenshots, diagrams, and anything with text, hard edges, or transparency.
JPEG quality: what the slider actually does
JPEG quality is a number from 0 to 100 that controls how aggressively the DCT coefficients get quantized. It’s not a linear scale. The sweet spot for web photos is 75–85. Below 60 you start seeing visible block artifacts in flat areas like sky gradients. Above 90 you’re adding file size with almost no perceptible quality gain.
Quality Typical 1920x1080 photo size 100 1.8 MB (wasteful) 95 900 KB 85 430 KB (recommended for photos) 75 280 KB (web default) 60 170 KB 50 140 KB (visible artifacts) 30 90 KB (clearly degraded)
Save once from the source at quality 85. Never re-save a JPEG at high quality expecting to recover detail — once it’s gone, it’s gone, and each re-encode introduces additional loss (“generation loss”).
WebP: the modern default
WebP beats JPEG at the same visual quality by roughly 25–35% file size, and adds transparency support. It’s been supported by all major browsers since 2020, so there’s no practical reason not to ship it. A 430KB JPEG at quality 85 is typically a 290KB WebP at the same visual fidelity.
The usual pattern: serve WebP with a JPEG fallback using <picture>, or let a CDN handle content negotiation via the Accept header. AVIF is even smaller (~50% of JPEG) but has slower encoding and lower tooling support — use it for your largest images only.
PNG optimization
PNG is lossless, which means “compression” means finding a better encoding, not discarding data. Key knobs: color palette reduction (PNG-24 truecolor to PNG-8 palette can cut size by 70% if the image has fewer than 256 distinct colors — icons and diagrams often do), filter and compression level (zlib levels 0–9; 9 is slowest and smallest), and chunk stripping (removing metadata chunks like tEXt and iTXt).
Tools like pngquant and oxipng can reduce a typical PNG screenshot by 40–70% with no visible change. For photographic content, always prefer JPEG or WebP over PNG — PNG-on-photos is 5–10x the file size of JPEG for the same perceived quality.
Target sizes by context
Context Target size Format Hero image 150-400 KB WebP or JPEG q80 Blog inline photo 80-200 KB WebP or JPEG q80 Thumbnail 15-40 KB WebP Product grid 50-120 KB WebP Social share (og) 200-400 KB JPEG q85, 1200x630 Email newsletter max 100 KB each JPEG q75 Favicon < 10 KB total PNG or ICO Mobile app icon 40-80 KB PNG-8
These are photo-realistic targets. Flat illustrations in SVG ship at 2–10KB and should almost always be used over raster for logos, icons, and diagrams.
Resolution before compression
Compressing a 6000×4000 image to 200KB damages it more than resizing first to 1920×1280 and compressing. The compressor has fewer pixels to work with, so the per-pixel bitrate is higher. Always resize to the display dimension (or 2x for Retina) before compressing. A 400px-wide card thumbnail doesn’t need a 4000px source.
Mobile vs desktop
A desktop visitor on fiber can absorb a 500KB hero image without noticing. A mobile visitor on a rural 4G tower feels every extra 100KB. Use responsive images with srcset to serve smaller files to smaller screens:
<img
src="hero-1280.webp"
srcset="hero-640.webp 640w,
hero-960.webp 960w,
hero-1280.webp 1280w,
hero-1920.webp 1920w"
sizes="(max-width: 768px) 100vw, 1280px"
alt="..."
loading="lazy">This serves a 60KB 640-wide file to phones and a 350KB 1920-wide file to desktops from the same markup. The loading="lazy" attribute defers offscreen images until scroll.
EXIF stripping
Photos from phones and cameras carry EXIF metadata: GPS coordinates, camera model, lens, exposure settings, sometimes the photographer’s name. This adds 5–50KB per image and, more importantly, can leak location data you didn’t intend to publish — a photo of your kid’s birthday party can geotag your home address. Strip EXIF on any image going to the public web unless you have a specific reason to keep it (photojournalism, stock photography attribution).
Progressive JPEG
A progressive JPEG loads in layered passes — blurry preview, then sharper, then final — instead of top-to-bottom. On slow connections the user sees something meaningful fast. File size is nearly identical to baseline JPEG (often slightly smaller). Most encoders have a “progressive” or “interlaced” checkbox; turn it on.
Batch compression
For an existing site with hundreds of uncompressed images, run a one-time batch pass with tools like sharp, imagemin, or squoosh-cli. A reasonable pipeline: resize to max 1920 wide, convert to WebP at quality 80, write both WebP and a JPEG fallback, strip EXIF. For a marketing site, you’ll typically cut total image weight by 60–80%.
Common mistakes
Saving the same JPEG multiple times. Each re-encode loses quality. Keep a lossless master (PNG or original) and re-export JPEG from that every time.
Using PNG for photographs. PNG is 5–10x larger than JPEG for photos at no perceived quality benefit. Use PNG only for screenshots, diagrams, transparency, or images with sharp text.
Compressing a 6000px source to 200KB. Resize first. The per-pixel quality is far higher when you compress a 1920px image to 200KB than when you squeeze 24 million pixels into the same budget.
Forgetting to set quality explicitly. Default JPEG quality varies wildly across tools — 75 in some, 95 in others. Set it.
Leaving EXIF metadata on public photos. GPS coordinates, device model, and timestamps go out with every upload unless you strip them.
Shipping one size for all screens. A 1920px hero image is overkill on a 375px phone and wastes bandwidth. Use srcset.
Skipping WebP because of “browser support.” WebP has 99%+ global support as of 2024. It’s safe to ship.
Run the numbers
Compress photos without a desktop app using the image compressor. Pair with the image resizer to scale dimensions before compression for dramatic size gains, and the EXIF remover to strip location and device metadata before publishing.
Use these while you read
Tools that pair with this guide
- Image CompressorReduce JPG file sizes with a quality slider and download optimized images for emails or websites. A free, instant online compressor that works in your browser with no signup.File & Format Converters
- Image Format ConverterSwap between JPG, PNG, and WebP formats instantly in your browser for quick edits before sharing. A free, online tool with no upload required and no sign-up needed.File & Format Converters
- Image ResizerScale JPG, PNG, or WebP photos by exact pixels or percentage while keeping the aspect ratio. A free, instant online resizer that works offline with no signup required.File & Format Converters
- Dummy Image PlaceholderGenerate placeholder images with custom sizes and colors online. Download or copy to clipboard in seconds — free, browser-only tool with no ads.Audio, Video & Voice
Advertisement
Continue reading
- How-To & LifeHow to Start Drone PhotographyStart drone photography the right way: understand FAA Part 107 and TRUST, pick a drone tier, avoid no‑fly zones, and master ND filters. Free instant guide, no sign-up.
- How-To & LifeHow to Pick Colors From ImagesExtract colors from images using eyedropper tools—hex at cursor, screenshot sampling, brand matching. A free online workflow guide with accessibility tips, no sign-up.
- How-To & LifeHow to Extract Colors From ImagesCompare dominant vs average color extraction and grab brand palettes from logos. Free online guide on algorithms and use cases with instant access.
- How-To & LifeHow to Blur Faces in PhotosBlur faces using pixelation or Gaussian techniques, and learn why mild blur can be reversed. A free online guide for privacy-safe censoring in seconds.
- How-To & LifeHow to View EXIF Metadata in PhotosExtract hidden camera data and settings from any photo with a free, online EXIF viewer. Verify image authenticity and check capture time instantly in your browser, no sign-up.
- How-To & LifeHow to Remove EXIF Metadata From PhotosStrip GPS, camera, and time data from images losslessly free online. Protect your privacy by understanding EXIF risks instantly with no download needed.