matplotlib: ValueError: invalid PNG header

前端 未结 2 2082
一整个雨季
一整个雨季 2021-01-04 19:52

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

2条回答
  •  清歌不尽
    2021-01-04 20:02

    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.

提交回复
热议问题