Python:读取png图像的默认/常用方法
我还没有找到Python 中读取图像的标准方法。真的没有吗(因为有这么多自定义的功能,我真的很想知道没有读取图像的功能)?或者它是什么? (它应该在 MacOSX 标准安装和 Linux 发行版的最新版本中可用。)
如果没有,最常见的库是什么?
很多搜索结果都提示我Python Imaging Library。如果这是一些众所周知的用于读取图像的 Python 库,为什么它不包含在 Python 中?
I haven't found a standard way in Python to read images. Is there really none (because there are so many functions for so many custom stuff that I really wonder that there are no functions to read images)? Or what is it? (It should be available in the MacOSX standard installation and in most recent versions on Linux distributions.)
If there is none, what is the most common lib?
Many search results hint me to Python Imaging Library. If this is some well known Python-lib for reading images, why isn't it included in Python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,标准库中没有用于直接读取/写入/处理图像的模块。但最常见的库可能是 PIL(Python 成像库)。许多项目未包含在标准库中,因为它们 1) 完全可选,2) 无法由少数 Python 核心开发人员维护。
No, there are no modules in the standard library for reading/writing/processing images directly. But the most common library might be PIL (Python Imaging Library). Many projects are not included in the standard library because they are 1) totally optional and 2) cannot be maintained by the few Python core developers.
来晚了,我强烈建议 ImageMagick 的 Python 接口之一 库(Wand 在我的测试中运行良好,我很快就会知道更多...)
ImageMagick 是一个更强大的库,也是跨多种语言的事实上的标准。由于吸引了更广泛的基础,他们也因此拥有了更广泛的开发者基础。
Coming late to the party, I would strongly suggest one of the Python interfaces to the ImageMagick library (Wand worked well in my testing, I'll know more soon...)
ImageMagick is a more powerful library and also pretty well a de-facto standard across many languages. Appealing to a wider base, they also have a wider developer base as a result.
建议的 PIL 不支持隔行 PNG。当处理大量来自不同来源的 PNG 时,这可能会很烦人。
可以打开它们,但只能从中读取头信息,所有其他操作都会失败。
THe suggested PIL does not support interlaced PNGs. It can be quite anoying when dealing with lots of PNGs from different origins.
It is possible to open them, but can only read headerinformation from them, all other operations fail.