For some PNG images (all have sizes 50KB and below), this script fails:
img = Image.open('path_to_img')
img
with the error
UnidentifiedImageError: cannot identify image file
I have looked up similar issues, and successfully ran the script above and displayed the resulting image, with the addition of the line
ImageFile.LOAD_TRUNCATED_IMAGES = True
However, these images will be used by a third-party function containing the original script, which I cannot alter. The third-party function must also use all the images in the dataset. Therefore my only option is to ensure that the images are not truncated and/or do not trigger an UnidentifiedImageError
. How can I efficiently convert these images to a usable format?