Python处理图像

ValueError: Only know how to handle extensions: [u'png']; with Pillow installed matplotlib can handle more images

意思是安装了pillow后, matplotlib就可以处理更多的图片格式了,因为默认情况下matplotlib只能处理png格式,现在要让它处理jpg格式,就需要安装pillow来解决了。

官网的解释是这样的:

matplotlib.pyplot.imread(*args, **kwargs)
Read an image from a file into an array.
fname may be a string path, a valid URL, or a Python file-like object. If using a file object, it must be opened in binary mode.

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.

Return value is a numpy.array. For grayscale images, the return array is MxN. For RGB images, the return value is MxNx3. For RGBA images the return value is MxNx4.

matplotlib can only read PNGs natively, but if PIL is installed, it will use it to load the image and return an array (if possible) which can be used with imshow(). Note, URL strings may not be compatible with PIL. Check the PIL documentation for more information.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值