Loops

Verify Image Assets Are Real Images

Checks that every image file in your project is actually the image format its file extension claims.

Anyone whose AI assistant or asset pipeline has left behind broken, empty, or mislabeled image files.

The problem

A generated or downloaded image can end up as a corrupted file, an HTML error page saved with a .jpg extension, or 0 bytes, and it will still show up in a file listing looking normal. Opening every image to check it by eye does not scale.

1. Work list

The command that lists every item. No AI involved.

find ./public ./src -iregex '.*\.\(jpg\|jpeg\|png\|webp\|gif\)$' -type f

2. Unit of work

One item is one image file.

3. The check

The checker runs file --mime-type <file> and compares the result to the type its extension implies (.jpg to image/jpeg, .png to image/png, and so on). Exit code 0 if they match and the file is larger than 0 bytes. Exit code 1 if the mime type does not match or the file is empty, printing the mismatch.

4. Stopping rule

Each bad file gets up to 3 replacement attempts before quarantine, ending when every file in the work list is checked.

What this cannot catch

This proves the bytes form a valid image of the right format. It does not prove the image is the right one, in focus, or not visually broken.

Build it

Install justloopit, then describe this task in your AI coding tool. It will ask about your project, then write the checker, the runner, and the spec.

Install

Build a loop