#!/usr/bin/env python
from struct import unpack

def read_info_1(filename):
    with open(filename, "rb") as f:
        f.seek(18)
        width, height = unpack("ii", f.read(8))
        f.seek(2, 1)
        bpp = unpack("H", f.read(2))[0]
    return width, height, bpp

def read_info_2(filename):
    try:
        with open(filename, "rb") as f:
            f.seek(18)
            width, height = unpack("ii", f.read(8))
            f.seek(2, 1)
            bpp = unpack("H", f.read(2))[0]
        return width, height, bpp
    except Exception as e:
        e.add_note(f"Processed file: {filename}")
        raise

if __name__ == "__main__":
    files = ["coffee.bmp", "no_data.bmp"]
    infos = [read_info_2(filename) for filename in files]
    for width, height, bpp in infos:
        print(f"Width: {width} px")
        print(f"Height: {height} px")
        print(f"Color depth: {bpp} bpp")

