import matplotlib.pyplot as plt
I tried to imread a png photo among many other png photos in the same folder. Some photos read with no errors using the
As @MichM has already stated that somehow the header of your image has changed and it is not a valid png image. Read the image as
plt.imread(filename, 0)
If you read the Matplotlib imread's doc at https://matplotlib.org/api/_as_gen/matplotlib.pyplot.imread.html?highlight=imread#matplotlib.pyplot.imread
--> If format is provided, will try to read file of that type, otherwise the format is deduced from the filename. If nothing can be deduced, PNG is tried. <--
It turns out someone must have manually changed the jpg files into the png extension before I got those files. These files open correctly in the picture viewer from the OS, hence look indistinguishable from the actual png files in the same batch, but they can't be processed by python scripts as png files -- because they are not. They don't have the alpha channel.