How does file compression/ZIP files work?

244 viewsEngineeringOther

I understand it’s to save file space, but like…how?

Follow-up: If you have to compress a photo to save on file size (when emailing, for example) couldn’t it just send essentially a text file on how to uncompress it back to its original size and quality? (ex. “Set the resolution to XxY and add X color at Y pixels”)

Thank you!

In: Engineering

9 Answers

Anonymous 0 Comments

elii5 answer:

1111111111111111111111111111111111111

versus

1010001

The 1st is 40 long. The 2nd binary 101000 = decimal (2*2*2*2*2) 0+(2*2*2)+0+0+0 = decimal 40 and now it takes 7 characters.

7/40 is 17.5% of the original file.

* The actual process is so efficient that text files are roughly 10% of the actual fie.
* The last 1 is not needed but used to keep it simple: basically you KNOW it is a group of 1s as the group before and after are always 0 (otherwise it would be 41 or more 1’s)

“couldn’t it just send essentially a text file on how to uncompress it back to its original size and quality? (ex. “Set the resolution to XxY and add X color at Y pixels”)”

Too complex and you also need to take in account that files can get damaged during transport. Compression also has a check digit to make sure it can be repaired when it arrives at the other end.

You are viewing 1 out of 9 answers, click here to view all answers.