What the inspector checks
| Check | What it catches | Fix explained in |
|---|---|---|
| First bytes vs name | HTML error pages saved as .jpg, HEIC renamed to JPEG, PDFs, SVGs, ZIPs | cannot identify image file |
Image.open() | Formats Pillow cannot read or needs a plugin for (HEIC), decompression bombs | converting formats, DecompressionBombError |
load() | Cut-off downloads and damaged files, which open fine and fail later | image file is truncated |
| Mode | 16-bit, 32-bit, float, CMYK, palette and alpha images that break convert(), JPEG saving or NumPy code | image modes, cannot write mode |
| ICC profile | Display P3 and Adobe RGB photos whose colours shift when the profile is dropped | ImageCms |
| EXIF | Photos stored sideways, and GPS locations you may not want to publish | EXIF |
| Size | Images large enough to exhaust memory once converted | resizing |
How the script is tested
The build runs the generated script with Pillow 13.0.0 on real and deliberately broken files: a
Display P3 photo, a sideways phone photo, an iPhone HEIC, a transparent PNG, an animated GIF, a 16-bit PNG, a web page saved
as .jpg, a half-downloaded JPEG, an empty file, an SVG and a PDF. Each must produce the expected diagnosis, or the
build fails. In the browser it runs on Pillow's WebAssembly build (Pyodide), which can lag a release behind and is built without
AVIF support and without LittleCMS; the version and features are printed at the end of the report, and the colour-profile name
is read directly from the file so that check works there too.
Running it on your own computer
Copy the script, change PATH to your file and run it. It needs only Pillow; if pillow-heif is
installed it also checks HEIC and HEIF files. To check a whole folder, wrap everything after PATH in a function and
call it for each file, as in processing all images in a folder.