Recitation 2: Image Files

In this recitation, you will explore how image files are stored.

Preparation

Prepare by watching: “How Computers Work: Binary & Data”

Activity

This activity should be completed individually, though you are welcome to ask other students, the TAs, or the instructor for help.

Task 1: View the File Sizes of Two Photos

  1. Use your phone to take two photos:
    • For one photo, cover the lens of your camera with your finger
    • The other photo can be of anything else in the room
  2. Copy these photos from your phone to your computer
  3. Record the file sizes of each photo:
    • On macOS: Right-click on a photo, then choose “Get Info”
    • On Windows: Right-click on a photo, then choose “Properties”
  4. Using the table shown below, convert the file sizes (likely displayed as MB, or megabytes) to bytes
  5. Discuss with a neighbor:
    • Which photo is the largest (i.e., has the most bytes)?
    • Why do you think that photo is the largest?
Metric Size
byte \(8\) bits
kilobyte (KB) \(1000\) bytes
megabyte (MB) \(1000^2\) bytes
gigabyte (GB) \(1000^3\) bytes
terabyte (TB) \(1000^4\) bytes

Task 2: Resize a Photo

Next, you will resize a photo so it takes up less space on your computer.

  1. Install GIMP, a free graphics editor
  2. Open the larger of your two photos in GIMP
  3. Choose “Image”, “Scale Image…”
    • A window will open, showing the dimensions of the image, in pixels.
    • Edit the width (e.g., to 500 pixels)
    • Click on the height, and you will see that it is updated automatically. This is done to preserve the aspect ratio, or else the image will appear stretched.
    • Finally, click “Scale”
  4. Choose “File”, “Export As…”
    • Name your file to distinguish it from the original photo (e.g., name it “resized”)
    • Click “Select File Type (By Extension)”, then choose “JPEG image”
    • Click “Export”, then “Export” in the window that appears
  5. Compare the file sizes of the resized photo to the original. Which is larger?
  6. Compare the file types of the two photos. Are they the same, or different? Many different image file formats exist. Each image format stores images differently, which impacts file size. Common formats are:
    • PNG: Portable Network Graphics
    • JPEG: Joint Photographic Experts Group
    • HEIF: High Efficiency Image File Format
    • TIFF: Tagged Image File Format

Task 3: Experiment (Optional)

Submit

Upload a PDF to Moodle containing: