How to Compress Images Without Losing Quality
A practical workflow for making images smaller while protecting the detail, dimensions, and transparency that matter.
In this guide
Compressing an image “without losing quality” can mean one of two things. You may need the decoded pixels to remain exactly the same, which calls for lossless compression. Or you may need a much smaller file that looks unchanged at its intended display size, which usually means careful lossy compression. Those are different goals, and choosing the right one is the first step.
For screenshots, diagrams, logos, or files that will be edited again, keep a lossless master and use PNG or another suitable lossless format. For photographs delivered on a website, a well-sized JPG, WebP, or AVIF can often discard data that viewers will not notice. The MDN image format guide explains which common formats support lossy compression, lossless compression, transparency, and animation.
Decide what “quality” must preserve
Quality is not a single setting. Before touching a slider, identify what the finished image must retain:
- Pixel accuracy: required for test fixtures, archival masters, technical imagery, and assets that will be compared pixel by pixel.
- Fine detail: important in hair, fabric, foliage, product texture, and low-contrast areas.
- Sharp edges and text: important in screenshots, interface captures, charts, and logos.
- Transparency: required when the image must sit cleanly on different backgrounds.
- Dimensions: important when the file must fill a particular layout or support high-density displays.
This distinction prevents a common mistake: selecting a high quality value while leaving an image far larger than it will ever be displayed. Excess dimensions can cost more bytes than a modest encoder adjustment saves.
| Image job | What must be preserved | Sensible starting point |
|---|---|---|
| Photograph on a web page | Natural detail at the rendered size | Resize to the largest required display size, then test JPG, WebP, or AVIF |
| Screenshot with text | Crisp edges and readable type | Keep PNG; try lossless optimization first |
| Logo with transparency | Clean edges and alpha transparency | Keep PNG if no vector source is available |
| Image for repeated editing | Maximum source information | Preserve the original master; export separate delivery copies |
| Email or form upload | Legibility within a file-size limit | Resize first, then lower lossy quality in small steps |
A reliable compression workflow
1. Preserve the original
Work from a copy. Lossy encoding removes information, and saving the result again can compound artifacts. An untouched source also lets you produce a different size or format later without starting from an already compressed derivative.
2. Set dimensions for the real use case
If a photo is 4,000 × 3,000 pixels but will be displayed at no more than 1,200 × 900, the source contains 12 million pixels while the delivery image needs about 1.08 million. Resizing removes work the browser would otherwise do and avoids transferring pixels the layout never shows.
Use the TinyImage resize tool when you know the target width. For responsive sites, create enough source sizes for the browser to choose an appropriate file rather than sending the largest version to every screen. The web.dev guide to responsive image syntax shows how srcset and sizes describe those alternatives.
3. Match the format to the content
PNG is a strong fit for flat graphics, screenshots, and transparency. JPG remains practical for photographs and broad software compatibility. WebP and AVIF offer modern delivery options, but the best result depends on the source and encoder—not simply the file extension.
If exact pixels matter, preserve the source and use a tool documented to perform only lossless optimization. TinyImage's PNG compressor may test reduced-color palette candidates to find a smaller web image, so inspect gradients, transparency, and exact brand colors rather than treating its output as proof of pixel identity. For a photo, compare JPG compression, WebP compression, and AVIF compression using the same source dimensions. Do not compare unrelated images or different crops.
4. Change one setting at a time
Start near the higher-quality end, export once, and inspect the result. Then lower quality in small steps until file size improves without damaging the details that matter. Quality numbers are encoder-specific: a value of 80 in one codec or application is not guaranteed to match 80 in another.
Lossless formats work differently. The PNG specification defines PNG encoding as lossless, so a conforming decode reproduces the samples that were given to the encoder. An earlier resize or palette-reduction step can still change those samples. A workflow is only pixel-preserving when every processing step—not just the final file format—is lossless.
5. Inspect at the intended size—and at 100%
Check the whole image at its final display size first. Then zoom to 100% around the areas most likely to reveal damage:
- edges around text or product silhouettes;
- smooth skies and gradients, where banding can appear;
- faces, hair, leaves, or fabric, where detail can smear;
- dark areas, where block artifacts may be easy to miss;
- transparent edges, where halos can appear against a new background.
The final display check answers “Will a viewer notice?” The 100% check catches defects that may become visible on a larger screen or after a later crop.
6. Measure the delivered page, not only the file
Compression is one part of image performance. A browser may still download an unnecessarily large source, delay an important image, or shift the layout if width and height are missing. The web.dev image performance guide covers transfer size, responsive delivery, lazy loading, and the effect images can have on page loading.
When lossless compression is the right answer
Use lossless compression when a changed pixel would be a defect rather than an acceptable tradeoff. Typical examples include a UI screenshot used in documentation, a diagram with small labels, a source asset moving between editors, or an image used for automated visual comparison.
Lossless does not guarantee a tiny file. A photo contains many subtle color changes, so a lossless PNG version can be much larger than a carefully encoded JPG or WebP. In that case, keep the lossless master privately and publish a separate lossy derivative.
When “visually unchanged” is enough
For website photographs, marketplace images, social posts, and email attachments, viewers usually care about the appearance at a particular size—not whether every source pixel survived. A controlled lossy export can be the better delivery file.
The important word is controlled. Use the original once, resize deliberately, choose a format for the content, and inspect the output. Avoid the cycle of downloading a compressed image, editing it, and compressing it again.
Common reasons compressed images look worse
- The source was already heavily compressed. Another lossy pass exposes existing block and ringing artifacts.
- Dimensions were reduced too far. No quality setting can restore pixels removed during resizing.
- The wrong format was chosen. JPG can blur hard text edges, while PNG can be inefficient for photographs.
- Transparency was flattened unexpectedly. JPG has no alpha channel, so transparent areas need a chosen background.
- Only the file size was checked. A small result is not useful if a product label or chart text is unreadable.
Frequently asked questions
Can an image become smaller with absolutely no quality loss?
Yes, when a lossless encoder finds a more efficient representation or removes nonessential metadata. The amount saved depends on the source. If the pixels must remain identical, use a verified lossless workflow rather than a “high quality” lossy preset.
Does a 100% quality setting mean lossless?
No. A quality slider belongs to a particular encoder and does not change a lossy format into a lossless one. It may also produce a much larger file for little visible improvement.
Should I resize or compress first?
Start from the original, resize to the required delivery dimensions, and then encode or compress that resized version. This avoids applying lossy compression twice and lets the encoder work on the pixels you will actually deliver.
Why should I keep both the original and compressed image?
Keep the original when you may edit, crop, reformat, or export at another size later. Treat compressed web files as delivery copies, not replacement masters.