Lossless and Lossy
- Terminology and concepts to look out for: compression · lossless · lossy
- Relevance to me: Photos, songs and videos on your phone are stored as compressed files. Today you learn the two kinds of compression and how they are different.
- Board Question: You text a photo to a friend. Is the photo your friend gets the same photo you took? Yes or no, and one reason. You answer this three times today: now, at your table, and on the exit ticket.
Chromebooks closed for now. Lab notebook open.
Lossless and Lossy Compression
This section explains two ways a computer makes a file smaller.
What Compression Does
A computer stores every file as a series of bytes, and each byte is 8 bits that hold a number from 0 to 255. A photo, a song and an essay are each a long list of these numbers. Compression is a way of making a file smaller by storing its information in fewer bytes. A smaller file occupies less storage and requires less time to transmit. Compression has two steps: the file is first encoded into a shorter form, and it is later decoded into a form that a program can use.
For example, when a photo is sent as a text message, the phone company may limit the size of the attachment, so an iPhone can compress the photo before sending it. An iPhone can also be set to send lower-quality images, which keep less detail. Copying a file is not an example of compression, because the copy is the same size as the original and holds the same bytes. The two kinds of compression differ in whether the decoded file matches the original exactly.
How Lossless Compression Works
Many files contain repeated patterns. Lossless compression is compression that records repeated patterns in a shorter form, so that the decoded file is identical to the original. For example, the string "AAAAAA" could be written as "6 A" and then rebuilt exactly. ZIP files usually use a lossless method called DEFLATE. First, DEFLATE looks for a string of characters that already appeared earlier in the file. Next, it replaces the repeated string with a short pointer that records how far back the earlier copy is and how long it is. When the file is decompressed, each pointer is replaced with the characters it points to.
For this lesson, the text of the DEFLATE standard was saved as a plain text file of 36,944 bytes. The zipped file took 11,345 bytes, and the unzipped file was 36,944 bytes again with 0 characters different. A zipped essay works the same way, because every character returns to its original position. For this reason, lossless compression is used for text files and computer programs, where one wrong character can change the meaning. A JPEG photo is not lossless, because some of its detail is gone and cannot be rebuilt.
How Lossy Compression Works
Photos, songs and videos are often stored with a different kind of compression, one that gives up some accuracy. Lossy compression is compression that removes some detail, so the decoded file is only close to the original and cannot be rebuilt exactly. JPEG became a standard format for photos in 1992. First, a JPEG encoder splits the photo into blocks of 8 by 8 pixels and turns each block into a set of 64 values. Next, it divides each value by a number from a table and rounds the result. The rounding removes detail, and the example tables in the standard were based on tests of what the human eye notices. Finally, the rounded values are stored in a compact code.
The program that saves a JPEG selects the table, so one photo can be saved with more or less detail. Figure 1 shows one photo of Jackson Square saved three times. Save 1 is 686,688 bytes, save 2 is 190,572 bytes, and save 3 is 85,533 bytes. All three have identical dimensions: 1,280 by 1,631 pixels. Save 3 kept the least detail, and its sky shows visible bands of color. A song from a streaming app is often lossy as well, and Spotify, for example, lists Lossless as a separate quality setting. A zipped essay is not lossy, because every character comes back.
When Detail Is Lost Again
Copying a JPEG file keeps every byte, so it removes no additional detail. Detail is lost again only when the picture is decoded and compressed a second time. Figure 1 also shows a chain of four pictures made to imitate a screenshot of a screenshot. Each step shrank the picture to four-fifths of its width and height and then saved it again as a JPEG. Screenshot 1 is 93,351 bytes, and screenshot 4 is 28,499 bytes. Each step removed additional detail, and no later step restored any of it. By screenshot 4, the lost detail is easy to see in the edges of the clock.
The Oct 6 reading, Ted Chiang's essay "ChatGPT Is a Blurry JPEG of the Web," used this idea of lossy compression to describe a chatbot. Monday's lesson continues that comparison.
Summary
Compression makes a file smaller by storing its information in fewer bytes. Lossless compression, used in ZIP files, gives back every byte of the original, while lossy compression, used in JPEG photos, removes detail that cannot be rebuilt. A JPEG loses more detail only when it is compressed again, as in a screenshot of a screenshot.
Sources: Deutsch, RFC 1951: DEFLATE Compressed Data Format Specification (1996); PKWARE, APPNOTE.TXT .ZIP File Format Specification (2022); CCITT, Recommendation T.81 (1992); JPEG committee, Overview of JPEG 1 (n.d.); NIST, The Binary Prefixes (n.d.); Apple Support, If You Can't Send or Receive Messages (2026); Spotify Support, Audio Quality (n.d.); Chiang, ChatGPT Is a Blurry JPEG of the Web (2023); Highsmith, St. Louis Cathedral on Jackson Square (Library of Congress); classroom data, Three JPEG Saves, Screenshot Chain and ZIP Round Trip (2026).
I Do questions
-
notebook cue: compression
Compare a file before and after compression. What is the one thing that has changed for certain?
Check
The file's size has changed: the compressed file takes fewer bytes. Whether anything else changed depends on the kind of compression. See What Compression Does, paragraph 1.
-
notebook cue: lossless
You zip an essay and unzip it. How many characters are different?
Check
Zero. ZIP uses lossless compression, so the unzipped file is identical to the original; in the test described in the passage, a 36,944-byte text file came back with 0 characters different. See How Lossless Compression Works, paragraph 2.
-
notebook cue: lossy
You save a photo as a JPEG, then save that JPEG as a JPEG again. What happens to the detail, and can you get it back?
Check
Saving it again as a JPEG compresses it a second time, so more detail is removed, and that detail cannot be rebuilt. Only a re-compression does this; a plain copy of the file keeps every byte. See How Lossy Compression Works, paragraph 1, and When Detail Is Lost Again.
I Do questions
-
notebook cue: compression
Compare a file before and after compression. What is the one thing that has changed for certain?
Check
The file's size has changed: the compressed file takes fewer bytes. Whether anything else changed depends on the kind of compression. See What Compression Does, paragraph 1.
-
notebook cue: lossless
You zip an essay and unzip it. How many characters are different?
Check
Zero. ZIP uses lossless compression, so the unzipped file is identical to the original; in the test described in the passage, a 36,944-byte text file came back with 0 characters different. See How Lossless Compression Works, paragraph 2.
-
notebook cue: lossy
You save a photo as a JPEG, then save that JPEG as a JPEG again. What happens to the detail, and can you get it back?
Check
Saving it again as a JPEG compresses it a second time, so more detail is removed, and that detail cannot be rebuilt. Only a re-compression does this; a plain copy of the file keeps every byte. See How Lossy Compression Works, paragraph 1, and When Detail Is Lost Again.
Lossless and Lossy Compression
This section explains two ways a computer makes a file smaller.
What Compression Does
A computer stores every file as a series of bytes, and each byte is 8 bits that hold a number from 0 to 255. A photo, a song and an essay are each a long list of these numbers. Compression is a way of making a file smaller by storing its information in fewer bytes. A smaller file occupies less storage and requires less time to transmit. Compression has two steps: the file is first encoded into a shorter form, and it is later decoded into a form that a program can use.
For example, when a photo is sent as a text message, the phone company may limit the size of the attachment, so an iPhone can compress the photo before sending it. An iPhone can also be set to send lower-quality images, which keep less detail. Copying a file is not an example of compression, because the copy is the same size as the original and holds the same bytes. The two kinds of compression differ in whether the decoded file matches the original exactly.
How Lossless Compression Works
Many files contain repeated patterns. Lossless compression is compression that records repeated patterns in a shorter form, so that the decoded file is identical to the original. For example, the string "AAAAAA" could be written as "6 A" and then rebuilt exactly. ZIP files usually use a lossless method called DEFLATE. First, DEFLATE looks for a string of characters that already appeared earlier in the file. Next, it replaces the repeated string with a short pointer that records how far back the earlier copy is and how long it is. When the file is decompressed, each pointer is replaced with the characters it points to.
For this lesson, the text of the DEFLATE standard was saved as a plain text file of 36,944 bytes. The zipped file took 11,345 bytes, and the unzipped file was 36,944 bytes again with 0 characters different. A zipped essay works the same way, because every character returns to its original position. For this reason, lossless compression is used for text files and computer programs, where one wrong character can change the meaning. A JPEG photo is not lossless, because some of its detail is gone and cannot be rebuilt.
How Lossy Compression Works
Photos, songs and videos are often stored with a different kind of compression, one that gives up some accuracy. Lossy compression is compression that removes some detail, so the decoded file is only close to the original and cannot be rebuilt exactly. JPEG became a standard format for photos in 1992. First, a JPEG encoder splits the photo into blocks of 8 by 8 pixels and turns each block into a set of 64 values. Next, it divides each value by a number from a table and rounds the result. The rounding removes detail, and the example tables in the standard were based on tests of what the human eye notices. Finally, the rounded values are stored in a compact code.
The program that saves a JPEG selects the table, so one photo can be saved with more or less detail. Figure 1 shows one photo of Jackson Square saved three times. Save 1 is 686,688 bytes, save 2 is 190,572 bytes, and save 3 is 85,533 bytes. All three have identical dimensions: 1,280 by 1,631 pixels. Save 3 kept the least detail, and its sky shows visible bands of color. A song from a streaming app is often lossy as well, and Spotify, for example, lists Lossless as a separate quality setting. A zipped essay is not lossy, because every character comes back.
When Detail Is Lost Again
Copying a JPEG file keeps every byte, so it removes no additional detail. Detail is lost again only when the picture is decoded and compressed a second time. Figure 1 also shows a chain of four pictures made to imitate a screenshot of a screenshot. Each step shrank the picture to four-fifths of its width and height and then saved it again as a JPEG. Screenshot 1 is 93,351 bytes, and screenshot 4 is 28,499 bytes. Each step removed additional detail, and no later step restored any of it. By screenshot 4, the lost detail is easy to see in the edges of the clock.
The Oct 6 reading, Ted Chiang's essay "ChatGPT Is a Blurry JPEG of the Web," used this idea of lossy compression to describe a chatbot. Monday's lesson continues that comparison.
Summary
Compression makes a file smaller by storing its information in fewer bytes. Lossless compression, used in ZIP files, gives back every byte of the original, while lossy compression, used in JPEG photos, removes detail that cannot be rebuilt. A JPEG loses more detail only when it is compressed again, as in a screenshot of a screenshot.
Sources: Deutsch, RFC 1951: DEFLATE Compressed Data Format Specification (1996); PKWARE, APPNOTE.TXT .ZIP File Format Specification (2022); CCITT, Recommendation T.81 (1992); JPEG committee, Overview of JPEG 1 (n.d.); NIST, The Binary Prefixes (n.d.); Apple Support, If You Can't Send or Receive Messages (2026); Spotify Support, Audio Quality (n.d.); Chiang, ChatGPT Is a Blurry JPEG of the Web (2023); Highsmith, St. Louis Cathedral on Jackson Square (Library of Congress); classroom data, Three JPEG Saves, Screenshot Chain and ZIP Round Trip (2026).
Each table decides: same photo or not the same photo. The table agrees on one answer and names what, if anything, was lost on the way.
Chromebooks stay closed while your table talks. When the discussion form pops up, answer it right here under My View. Switch slides whenever you need the passage, and submit before the exit ticket.
Use this form at your table. At the start of class, you answered today's Board Question: You text a photo to a friend. Is the photo your friend gets the same photo you took? Yes or no, and one reason. Talk with your table about it, the three positions and the three statements. Then answer on your own.
MC 1. (Where you stand) At the start of class, you answered this question: You text a photo to a friend. Is the photo your friend gets the same photo you took? Yes or no, and one reason. After talking with your table, which position is closest to yours now?
- Yes. It is the same photo, sent to another phone.
- No. The app sent a smaller copy, and some detail was lost.
- It looks the same, so it does not matter whether it is the same file.
CR 1. (Board Question · answer 2) Think about the Board Question again. Did you reach the same conclusion you had at the start of class, or a different one? Say so in one sentence. Then write your answer as a claim: (1) State your answer as if it is a fact. (2) Support it with evidence from the passage. (3) Explain how that evidence supports your claim.
Write your answer in your lab notebook, labeled CR 1.
MC 2. (Statement 1) If two pictures look the same, the two files are the same.
- Agree
- Disagree
MC 3. (Statement 2) A zip file can always give back every character of the original.
- Agree
- Disagree
MC 4. (Statement 3) Saving a JPEG again and again can make it look worse.
- Agree
- Disagree
CR 2. (My view) Write one thing you said or thought at your table.
Write your answer in your lab notebook, labeled CR 2.
CR 3. (A different view) Write the view at your table that was most different from yours. If everyone agreed, write the strongest argument against your table's answer.
Write your answer in your lab notebook, labeled CR 3.