Shanraq.org Shanraq.org
Why ZIP and a messenger compress differently
Society

Informatics: build your own digital assistant Lesson 16 of 72

Why ZIP and a messenger compress differently

Compare lossless and lossy compression, then choose what is acceptable for our project data.

Where we are on the map

Why does a ZIP archive return the original text exactly, while a photo sent through a messenger may look softer? Both became smaller, but the methods make different promises.

Why ZIP and a messenger compress differently

Everyday analogy and exact model

Writing “4А3Б” instead of “ААААБББ” describes repetition more briefly. Someone who knows the rule can restore the original exactly. Shrink a photograph, however, and fine details can disappear; merely unpacking it cannot bring them back.

Lossless compression permits exact reconstruction. ZIP is in this category. Our “4А3Б” is only a teaching example: real size depends on encoded bytes, headers, and algorithms, so ZIP may make a short file larger. Lossy compression discards some information according to a rule for a smaller representation; the recovered picture or sound need not match byte for byte. A messenger may recompress media but may transfer an attachment as a file instead. Check the actual sending mode.

Two promises behind “compression”

Lossless compression lets you reconstruct the original bytes exactly; documents and programs need this. Lossy compression discards some detail considered less noticeable, so exact recovery is impossible. A compression ratio compares sizes before and after, but does not measure quality. An archive is a container for one or more files and may use compression internally. Renaming an extension performs neither method.

For the teaching string ААААБББ, the rule “count plus character” gives 4А3Б. Decode it as “four А, three Б” and restore the original. On short text, the rules themselves can take extra space, so do not promise savings every time. Now imagine a photo containing shades 200 and 201 that a simple method rounds both to 200: size may fall, but the former 201 cannot be recovered. This models loss; it is not a literal description of JPEG.

Copy tasks.json, put the copy in a ZIP file, and extract it. Compare the extracted and original files byte for byte or by SHA-256. A match proves exact restoration for this experiment. Assess a photo by visible quality and size as well; do not expect byte equality from a lossy format.

Where the analogy ends

“Compress” does not always mean “make smaller,” nor does it always mean “damage.” Choose according to what must be exact: task text and backups need lossless storage; a photographic preview may tolerate lost detail.

The lesson’s support signal

lossless → exact reconstruction; lossy → some details cannot be recovered

Worked example

ААААБББ has seven visible characters and our symbolic 4А3Б has four. Expand the latter back to seven. Do not claim that this saves three bytes: Cyrillic letters use more than one byte in UTF-8 and a real format must define the rule.

Predict before observing

Can you recover exact original RGB values after mapping every channel value 201 to 200? No: several originals might map to the same rounded result. Decide whether an exact copy is needed before choosing a format.

Do not jump straight to the answer. Write your prediction and its reason first. Compare each intermediate step as well as the final result. If you were right by chance, repeat with different values.

Reconstruct without a hint

Invent a repeated string, shorten it using the classroom rule, and reconstruct it. Then give an example of a photo detail lost by reducing resolution.

Cover the worked example with paper. Reconstruct the chain from the short support signal, explain every transition aloud, and then reveal the example to check yourself. If stuck, look back at only the preceding step.

Find and correct the mistake

“Sending a PNG in a messenger always damages it.” Correct the claim: treatment depends on sending mode. Compare source and received files, and transfer exact data as a file.

Transfer to a new situation

How should you keep an assistant task table and a small decorative photo? The table needs exact copying; you may show a reduced photo while preserving its original separately.

Project change

Write a FORMAT.md policy: tasks.json and its backup must be recoverable byte for byte; a preview cover may be optimized after checking readability. Do not replace the only original with a reduced copy.

Exercise

Choose suitable treatment for three objects: task list, project archive, and thumbnail. Justify each choice, then test reversibility using your own short repeated string.

Submit evidence that can be checked, rather than saying “I understood”: a table, calculation, file, or precise answer with a reason. Use fictional data. Ask another learner to repeat the action from your description; if they must guess, clarify the rule.

Return after 1, 7, and 30 days

Tomorrow name both compression types. In a week expand 4А3Б. In a month check whether another app preserved your transferred data.

Next lesson: How to detect damaged data

If you have found a mistake or a typo in this article, tell us about it

Check your project evidence

Enter your observation, explanation, error correction, and project change. The model will identify the first confused or unsupported link without giving you a finished answer.

Sign in to have it checked. Sign in

Comments (0)

No comments yet. Be the first.