@monsterjavaguns I was reading up on https://opensource.com/article/17/2/python-tricks-artists, good stuff. You do want to remove the catching of SyntaxError, though. That exception would indicate that there is an actual syntax error in your Python code -- that's not the kind of thing you want to handle as synonym for "this image is corrupt".
I've looked up the Pillow documentation, but they don't say which exceptions they use. Did you see them actually throw a SyntaxError?
@sybren Good catch. I've had an image throw a SyntaxError once... but I think I was doing something pretty unconventional with it (the image, that is). As such, I'd simply left the catch in my own code... and it found its way into the article. Suppose I should probably fix that.