Need Domain Help?  |  Buy a domain  |  Corporate Site
 
TUCOWS ARTICLE

Digital Imaging Part 2 - Lossy Vs. Lossless

Understanding image compression is really just a matter of thinking in numbers. This article explains the differences between lossy and lossless file formats and also discusses the pros and cons of digital image compression.
Published: May 2, 2006
Author: Stacy Reed
Advertisement

Understanding image compression is really just a matter of thinking in numbers. The number of bits that are stored and the number of pixels that make up the image are key factors. An uncompressed image with a resolution of 640 x 480 pixels has 307,200 pixels total. A true color (24 bit) image of that size would take about 1 MB of storage space considering each pixel uses 3 bytes. The file size increases with the image resolution, for instance, if we have a true color image resolution of 1024 x 768 pixels, it's going to take 2.5 MB of storage space. Now, imagine that you have a few 2.5 MB files on your server that are downloaded by everyone who visits your web site... you would probably use up a lot of bandwidth quickly!

Thankfully, we can compress image data to make the file smaller while retaining the size of the image. There are a lot of programs that can convert and compress your images with ease, in fact, most image editors can. Also, most digital cameras compress your images automatically so you can store more images and move them to your computer quicker. Smaller image files are easier to manage which is why compressed images are ubiquitous. Images can be compressed in two ways, lossless and lossy. The difference between the two is that lossless files retain their data while lossy files lose data.

Lossless files like TIFF, GIF and PNG are saved using algorithms that reduce file size but do so without losing image quality. Unfortunately, the compression ratios are quite a bit weaker than lossy. That means that it will ultimately be a larger file, but the quality will be well preserved. Usually, images that will be printed are saved with a lossless compression because the integrity of the image is more important than viewing it on the Internet, for example.

Lossy files like JPEG and JPEG2000 discard information when they are saved. The amount of information that is discarded directly influences the size of the file. It's important to note that once you save a lossy file, you can never go back to the previous state. Each time the file is opened and saved as a JPEG, it will lose more and more data which will cause the image to become pixelated. The reason for this is that pixel data is trashed during compression and when the image is reopened, the computer must fill in the missing data by borrowing from neighboring pixels. This also happens when an image has been saved using a very high compression ratio for the same reason.

Low compression = Higher quality image
High compression = Lower quality image



Take a look at these images for an example. The first image has been saved as a lossless PNG file (83.8 KB), the center has been saved with low compression (81.7 KB), and the third has been saved with high compression (45.5 KB). You can see the visual artifacting occurring most in the image that has been saved with the highest compression. It's up to you to decide if you want to compromise file size or quality when choosing image compression. If the file is to be placed on your website, consider how often people will download the file and how much strain a file that size could put on your bandwidth allowance. If a file is too large, it could take longer for your Web page to load and most people won't stick around to see. If the file is too small, viewers might not be able to make out what it is, or it could send the wrong message. It certainly doesn't look professional. When in doubt, choose a compression ratio that is somewhere in the middle and save it as a new file. Open it and see how it looks. If you don't like it, open the original file and save again until you get it just right.

Further Reading:
JPEG Image Compression FAQ
WorldStart's Image File Guide


About Stacy Reed

Software librarian and acclaimed artist seeks knowledge and entertainment via Internet. Stacy Reed is an advocate for free information, software and services. She began reviewing software for Tucows in 2000. She's naturally curious with interests in a wide array of subjects including science and technology, software, the arts, and open education.

Digg This
Recent Comments
leave a comment
Please login to add your comment
Leave A Comment
Name:
Advertisement
How do I use a digital SLR: Understanding your digital SLR's mode dial

Here we'll tell you how to best use the mode dial on your digital SLR camera! view it

How do I use a digital SLR
Beginners tips for Photobucket: Creating photo albums

How to create photo albums for your images on Photobucket! view it

Beginners tips for Photobucket
Tutorials: How to add a photo to a contact on your Android phone

Here we'll show you how to give your contacts pictures on your Android phone! view it

Tutorials
Photo Editing Tips with Picnik: Easy photo touch-ups in Picnik

Whiten that smile and lose those wrinkles with Picnik's easy touch-ups view it

Photo Editing Tips with Picnik
How do I use a digital SLR: An overview of digital SLR cameras

In this first episode we'll introduce you to what makes up a digital SLR camera! view it

How do I use a digital SLR
Beginners tips for Photobucket: Editing photos in Photobucket

Here's how to edit and modify your images online using Photobucket! view it

Beginners tips for Photobucket
Photo Editing Tips with Picnik: Making a photo collage in Picnik

Creating a fun photo collage is easy in Picnik view it

Photo Editing Tips with Picnik
How do I use a digital SLR: Using your digital SLR's aperture priority mode

Last episode we showed you how to use shutter priority mode on your DSLR, now we'll show you how to use aperture priority mode! view it

How do I use a digital SLR
Beginners tips for Photobucket: Uploading your first image

Here's how to load your first image to your Photobucket account! view it

Beginners tips for Photobucket