Voici la situation : j'ai un un dossier contenant plus de 4 000 fichiers (un mélange d'images aux formats PNG, JPG et Webp). Et parmi ces images, une seule est corrompue.
Je le sais parce qu'OpenCV renvoie ce message d'erreur, et je ne peux pas savoir de quelle image il s'agit puisque c'est un traitement par lot :

Premature end of JPEG file

Premier indice : il s'agit d'une image au format JPG.

La méthode, assez rapide, qui a fonctionné pour identifier l'image corrompue est la suivante (nécessite imagemagick) :

$ identify -regard-warnings data/images/*.jpg
identify-im6.q16: Premature end of JPEG file `data/images/7DSzZQ.jpg' @ warning/jpeg.c/JPEGWarningHandler/389.
identify-im6.q16: Corrupt JPEG data: premature end of data segment `data/images/7DSzZQ.jpg' @ warning/jpeg.c/JPEGWarningHandler/389.
identify-im6.q16: Corrupt JPEG data: found marker 0xd9 instead of RST5 `data/images/7DSzZQ.jpg' @ warning/jpeg.c/JPEGWarningHandler/389.
# (…)
identify-im6.q16: TooManyExceptions (exception processing is suspended) @ warning/exception.c/ThrowException/1054.

Et voilà la coupable : data/images/7DSzZQ.jpg