目录
安装冲突解决方法:windos和linux通用
windows下面两个安装命令是都可以:
pip install pillow pip install Pillow
pip uninstall PIL
PIL拷贝,剪切,缩放 格式转换笔记
pil拷贝,剪切,缩放 笔记_AI视觉网奇的博客-优快云博客
常见报错问题:
PIL(Python Imaging Library)是Python常用的图像处理库,而Pillow是PIL的一个友好Fork,提供了了广泛的文件格式支持,强大的图像处理能力,主要包括图像储存、图像显示、格式转换以及基本的图像处理操作等。
Pillow的文档:Pillow (PIL Fork) 9.3.0.dev0 documentation
Pillow的github:GitHub - python-pillow/Pillow: The friendly PIL fork (Python Imaging Library)
-----------------------------------------------------------------
0x0. Pillow的注意事项
Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.
Pillow >= 1.0 no longer supports “import Image”. Please use “from PIL import Image” instead.
Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as _imaging” instead.
Pillow < 2.0.0 supports Python versions 2.4, 2.5, 2.6, 2.7.
Pillow >= 2.0.0 < 4.0.0 supports Python versions 2.6, 2.7, 3.2, 3.3, 3.4, 3.5
Pillow >= 4.0.0 supports Python versions 2.7, 3.3, 3.4, 3.5, 3.6
0x6. PIL一些报错
ImportError:The _imagingft C module is not installed
这个是在windows里安装PIL所报错,建议直接exe安装。
PIL.Image.open() IOError: cannot identify image file
首先检查图片是不是正确的,如果各种检查过还是有问题建议重装PIL
0x7. Pillow报KeyError问题
python
>>> import Image
>>> Image.init()
1
>>> Image.SAVE.keys()
['PCX', 'HDF5', 'EPS', 'MSP', 'XBM', 'WEBP', 'BUFR', 'PPM', 'BMP', 'TGA', 'ICO', 'TIFF', 'JPEG', 'SPIDER', 'GIF', 'GRIB', 'IM', 'FITS', 'PDF', 'WMF', 'MPO', 'PALM', 'JPEG2000', 'PNG']
如果Image.SAVE.keys()输出为空,则说明没有找到save format key,在生成图片时就会报KeyError, 此时就需要把import Image改成from PIL import Image