This bug can arise from many issues, but the main one could be the fact that you’re saving the picture using the wrong extension. This will make a file that shows to be in an image format but is actually unreadable, just as recalling a text file to img.jpg would do.