Skip to content

Compress Images for Web and Boost Performance on Your Site

Slow-loading web content and problematic media displays that involve seemingly interminable scrolling tick off users to no end. Compressing online images is, without question, a critical task for spearheading customer retention for websites. Keep in mind that small images can still look sharp. This article shows you how to achieve that by mastering the techniques of compressing images for the web.

To compress images and, consequently, reduce their sizes, you apply a transformation technique that removes the image parts with a negligible or low visual effect on the display quality. Image compression can be lossless or lossy.

Lossless compression of images results in no loss of pixel data, significantly reducing their sizes with no quality compromise in the display. The examples below demonstrate lossless image-compression in play.

Here’s the original, uncompressed picture with a size of 2.58 MB:

Loading code examples Eden friends

Here’s the compressed version with a size of 918 KB:

Loading code examples Eden friends

The two pictures look the same even though the second one has undergone compression that reduced its size by almost 2 MB.

As its name implies, lossy compression causes loss of pixel data. That’s a result of the removal of certain image parts.

Before deciding which compression technique to adopt for your images, familiarize yourself with the results that the two techniques produce.

Applying lossless compression to images generates the following:

  • A lossless attribute for images that are of the GIF, BMP, RAW, or PNG file type.
  • An outstanding display.
  • Possibly less reduction in file size than that engendered through lossy compression.

Applying lossy compression to images generates the following:

  • A lossy attribute for images that are of the JPEG or GIF file type.
  • A greatly reduced file size.
  • Irreversible images: once you go lossy, you’re beyond the point of no return.
  • Possible degradation of image quality in case of application of extreme parameters.

Compressing online images yields remarkable benefits.

Large media files can hamper page-loading speed, hence potentially a huge bottleneck for content access. Compressing those files before or immediately after upload significantly improves user experience for websites.

Cloudinary, a stellar software-as-a-service (SaaS) platform for storing, managing, transforming, and delivering digital media, offers a free, eye-opening tool for analyzing a site’s loading experience. Have a whirl!

Regular periodic backups are key for data integrity. As a matter of course, backing up smaller image files takes less time and less resources.

Loading smaller files takes less bandwidth on the audience’s part, ensuring satisfaction and appreciation.

Even though data-storage options abound in the face of technology advances, be vigilant about economizing storage space at all times. Why? Because data racks up pretty fast over time, especially if your site contains media-heavy user-generated content.

Whether you’re leveraging third-party cloud storage or hosting it yourself, it’s a good practice to compress media files before storing them. Space optimization is paramount..

How does image compression benefit SEO? The answer is simple: speed is an ever-present criterion for ranking websites at search giants like Google.

The faster a webpage loads, the higher it ranks. Well-compressed images make your website load fast, which in turn raises the probability of a higher ranking on search matches.

The following articles I wrote in 2017 contain recommendations for image-compression tools for three development environments:

  • For PHP, Imagick works well. Built-in functions in PHP also compressing images. See the details in this article.
  • For WordPress, this article suggests several tools, from Imagify to Optimuss, with many amazing options.
  • For Ruby, read my take in this article.
  • For Python Image Optimization and Transformation, read more here

In addition, while uploading images to Cloudinary, you can efficiently automate image compression by adding —one line of code to the URL that contains the quality parameter according to the syntax q_, followed by the quality level on a scale of 0–100. For example::

Loading code examples sample

The higher the image quality, the larger the file size.

This recent post tells you the details. Do check it out.

Tip: To apply lossy compression to animated GIFs, follow the procedure described in this post.

Compressing images goes a long way toward making the web run faster. And the procedure involved is a breeze. Let’s swear off sending uncompressed images to our audience!

Back to top

Featured Post