【发布时间】:2015-01-15 16:20:13
【问题描述】:
我需要使用 python 3.4 创建一个白色位图文件。我已经在互联网上搜索过,但模块“Image”或“ImageDraw”在 Python 3.4 中不起作用。那么如何创建位图文件呢?或者也许我必须使用哪些模块?
【问题讨论】:
-
使用 PIL 解决方案效果更好
标签: python-3.x bitmap bmp
我需要使用 python 3.4 创建一个白色位图文件。我已经在互联网上搜索过,但模块“Image”或“ImageDraw”在 Python 3.4 中不起作用。那么如何创建位图文件呢?或者也许我必须使用哪些模块?
【问题讨论】:
标签: python-3.x bitmap bmp
获取枕头,在 2.6 到 3.4 运行。
pip install pillow
应该在命令行下工作(如果在 python34/Scripts 中也可以)。因为它是 PIL 的兼容分支,所以导入为PIL。我还没有使用它,但是从文档中,
from PIL import Image
im = Image.new(<specs>) # size, pixel deptch
im.save('x.bmp', ...)
应该做你想做的。
【讨论】: