DEV Community

Vijay Koushik, S. πŸ‘¨πŸ½β€πŸ’»
Vijay Koushik, S. πŸ‘¨πŸ½β€πŸ’»

Posted on • Originally published at svijaykoushik.github.io on

Social media reduces quality of photos

Data Compression: How social media changes quality of your photos

In a world, where smart phones have dual cameras that take high quality pictures with precision, how are those images shared instantly? We all know that higher the quality of the picture, higher is its file size. So, how do we share megabytes of data in a blink of an eye?

Social networking apps like Facebook, WhatsApp, Hike, Hangouts, Snapchat or whatever social networking app you have in your smart phone uses a technique called data compression. Data compression is a technique that employs algorithms to reduce file size by either reducing redundancy or by selectively removing certain parts of the image that is not perceptible to our eyes or sometimes they use both.

The first technique commonly called lossless compression identifies the redundant parts in a picture and removes redundant data keeping the necessary. For example, in a picture of a person wearing a black shirt the black shirt has redundant black pixels (tiny square dots that make up a digital image). The algorithm checks how many black pixels make up the shirt let’s say if it contains 2000 pixels then the algorithm will store data as 2000 black pixels for the shirt instead of 1, 2, ….. , 2000 pixels. By this way it reduces the size of the picture without quality loss. The compressed image can be reconstructed to its original form by this technique.

Image with low compression

Image with low compression.
Image with high compressionImage with high compression.

The second technique called the lossy compression on the other hand selectively removes parts of the image in such a way it is unnoticeable to our eyes until close inspection. Imagine a container full of gems candy. If my little brother takes 5 candies from it, I won’t notice any change until and unless I count the number of candies inside that container. So similarly, the algorithm removes minute details like the fine hairs on my nose from a picture to reduce the size. Sometimes visible quality loss of the picture occurs when highly compressed. This visible loss of quality is considered as a sacrifice for reduced data traffic. When using lossy compression the details lost are lost forever. Unlike lossless compression the original image cannot be reconstructed in lossy compression.

Images with ubiquitous formats like JPEG and PNG are surprisingly pre compressed images. They use lossy compression algorithm for compression. These standards were implemented for the mobility of data. Normally a HD image would take 5 MB to 10 MB or even more depending upon the camera. When shared, these pictures are compressed to about 5% of their original size. Imagine how much data you need to spend from your limited internet pack every time you share a picture and also the painfully long waiting time for uploading those pictures. And how many extra acres Facebook might need for its storage facility to accommodate all those selfies.

So the next time you upload a perfect selfie to Facebook or Instagram be glad that people cannot see your pores on your nose.


Top comments (0)