[list]
[*][color=red]IOError: cannot identify image file[/color]:表示路径对应的文件不是有效的图片
[*][color=red]ValueError: images do not match[/color]:表示图片大小和box对应的宽度不一致,参考API说明:Pastes another image into this image. The box argument is either a 2-tuple giving the upper left corner, a 4-tuple defining the left, upper, right, and lower pixel coordinate, or None (same as (0, 0)). If a 4-tuple is given, the size of the pasted image must match the size of the region.使用2纬的box避免上述问题
[*][color=red]IOError: image file is truncated[/color] (40 bytes not processed) :表示路径对应的图片文件已损坏,请确认
[*][color=red]IOError: Unsupported BMP header type[/color] (56):发现还是图片已损坏
[/list]
The Python Imaging Library supports a wide variety of raster file formats. Nearly 30 different file formats can be identified and read by the library. Write support is less extensive, but most common interchange and presentation formats are supported.
The open function identifies files from their contents, not their names, but the save method looks at the name to determine which format to use, unless the format is given explicitly.
PIL根据文件内容而不是文件名后缀来读取图片,但是保存的时候可以指定某种格式(文件名后缀和格式不匹配也可以),如下
srcImg.save(targetFullFile)
srcImg.save(targetFullFile, 'jpeg')
[*][color=red]IOError: cannot identify image file[/color]:表示路径对应的文件不是有效的图片
[*][color=red]ValueError: images do not match[/color]:表示图片大小和box对应的宽度不一致,参考API说明:Pastes another image into this image. The box argument is either a 2-tuple giving the upper left corner, a 4-tuple defining the left, upper, right, and lower pixel coordinate, or None (same as (0, 0)). If a 4-tuple is given, the size of the pasted image must match the size of the region.使用2纬的box避免上述问题
[*][color=red]IOError: image file is truncated[/color] (40 bytes not processed) :表示路径对应的图片文件已损坏,请确认
[*][color=red]IOError: Unsupported BMP header type[/color] (56):发现还是图片已损坏
[/list]
The Python Imaging Library supports a wide variety of raster file formats. Nearly 30 different file formats can be identified and read by the library. Write support is less extensive, but most common interchange and presentation formats are supported.
The open function identifies files from their contents, not their names, but the save method looks at the name to determine which format to use, unless the format is given explicitly.
PIL根据文件内容而不是文件名后缀来读取图片,但是保存的时候可以指定某种格式(文件名后缀和格式不匹配也可以),如下
srcImg.save(targetFullFile)
srcImg.save(targetFullFile, 'jpeg')
本文介绍了Python Imaging Library (PIL)中常见的图像处理错误及其解决办法,包括无法识别的图像文件、图片尺寸不匹配等问题,并提供了详细的解决方案及API使用说明。
5286

被折叠的 条评论
为什么被折叠?



