← Back to Blog How to Compress Images Without Losing Quality: JPG, PNG and WebP

How to Compress Images Without Losing Quality: JPG, PNG and WebP

Share:

Images are usually the heaviest part of a web page. A photo straight from a phone can be several megabytes. Large images slow the page down, use up mobile data and make visitors leave. You can fix most of this without any visible loss of quality.

Pick the right format

  • JPG: best for photos. It uses lossy compression, so the file gets much smaller.
  • PNG: best for logos, screenshots and graphics with sharp lines or transparency. It is lossless, so photos saved as PNG become very large.
  • WebP: a modern format that handles photos and transparency, and is usually smaller than JPG or PNG. All current major browsers support it.
  • AVIF: newer and often even smaller than WebP. Support is good in recent browsers, but check older ones if you need them.

Resize before you compress

A photo 4000 pixels wide shown in a column 800 pixels wide wastes data. The browser downloads every pixel and then shrinks the picture. Scale the image to the widest size your page really needs first. For most articles, 1200 to 1600 pixels wide is plenty, even for sharp phone screens.

Step by step

  1. Check the type. Photo or graphic? That decides the format.
  2. Resize. Set the width to what your layout needs.
  3. Compress. For photos, a quality of about 75 to 85 percent often cuts the size by half or more, with little visible change.
  4. Compare. Zoom in on text, edges and smooth gradients. Look for blocky patches or banding.
  5. Check the size. A common target is under 200 KB for a full-width image, and much less for thumbnails.

The AioGalaxy Image Tools page can compress, convert, resize, crop and watermark JPG, PNG, WebP, AVIF and GIF files. It shows a before and after slider so you can compare. According to the page, images are processed in your browser and are not uploaded to our server.

What about HEIC photos?

iPhones often save photos as HEIC. Many websites and older programs cannot open that format. Our Image Tools page does not list HEIC as a supported input, so convert the photo to JPG first. On an iPhone you can change this in Settings, under Camera, then Formats, by choosing "Most Compatible". Then compress the JPG as usual.

Before you upload

  • The dimensions match your layout, not the camera.
  • The format is JPG, PNG, WebP or AVIF.
  • You zoomed in and the text and edges still look clean.
  • The file name describes the picture, for example invoice-template-preview.webp, not IMG_4021.jpg.
  • You have written alt text for the image.

Common mistakes

  • Photos saved as PNG. The files are huge and look no better.
  • Compressing again and again. Each pass loses detail. Always start from the original file.
  • No alt text. Screen reader users and search engines need it.
  • No width and height in the HTML. The page jumps around while images load.

A worked example

Say you have a phone photo that is 4000 pixels wide and a few megabytes in size. Your article column is about 800 pixels wide.

  1. Keep the original file safe in a folder of its own.
  2. Make a copy and resize it to about 1600 pixels wide. That is twice the column width, so it stays sharp on high-density phone screens.
  3. Save it as WebP or JPG at a quality of about 80 percent.
  4. Look at the result at full size and check the edges, text and any smooth sky or wall.
  5. Check the file size. If it is still much larger than you expected, lower the width a little or try a slightly lower quality.

Results vary from photo to photo, so always judge the picture with your own eyes and not only by the number.

Keep your originals

Never overwrite the only copy of a photo with a compressed version. Compression throws data away, and you cannot get it back. Keep the originals in one folder and the web versions in another, with clear names, so you can make a new version later if your layout changes.

Images lower on the page

Images that appear far below the first screen do not need to load straight away. Browsers support the loading="lazy" attribute on images, which tells them to wait until the visitor scrolls near. Do not use it on the main image at the top of the page.

Smaller images are one of the easiest speed gains for a website. Choose the right format, resize first, compress gently, and check the result with your own eyes.

M
Written by Muhammad Faraz

Co-founder and developer of AioGalaxy. Builds and maintains the Eaglefly, AIVoice and free tools platforms, and writes the blog.

Enjoyed this? Explore the AioGalaxy toolset

Everything mentioned here — and a lot more — is free to try right now, no sign-up walls.

Explore AioGalaxy →

Comments

No comments yet — be the first to share your thoughts.