简体   繁体   English

Python 2D图像生成

[英]Python 2D image generation

What are some of the better libraries for image generation in Python? 在Python中,有哪些更好的图像生成库? If I were to implement a GOTCHA (for example's sake), thereby having to manipulate an image on the pixel level, what would my options be? 如果我要实现GOTCHA(例如),从而必须在像素级别操作图像,我的选择是什么? Ideally I would like to save resulting image as a low-resolution jpeg, but this is mere wishing, I'll settle for any common image format. 理想情况下,我想将结果图像保存为低分辨率jpeg,但这只是希望,我会满足于任何常见的图像格式。

Thank you for your attention. 感谢您的关注。

The Python Imaging Library (PIL) is the de facto image manipulation library on Python. Python Imaging Library(PIL)是Python上事实上的图像处理库。 You can find it here , or through easy_install or pip if you have them. 你可以在这里找到它,或者如果你有的话,可以通过easy_installpip找到它。

Edit: PIL has not been updated in a while, but it has been forked and maintained under the name pillow . 编辑:PIL暂时没有更新,但它已经在名称枕头下分叉和维护。 Just install it this way in a shell: 只需将它以这种方式安装在shell中:

pip install Pillow

The import statements are still the same as PIL (eg, from PIL import image ) and is backward compatible. import语句仍然与PIL相同(例如, from PIL import image )并且是向后兼容的。

Pillow is a fork of PIL that is still actively developed. Pillow是PIL的一个分支,仍然在积极开发。 While PIL is not dead it has been a number of years since the last release. 虽然PIL没有死,但自上次发布以来已有好几年了。

If you should generate text or other vector based images (and then save to .png or .jpg), you could also consider Cairo (PyCairo, in this case). 如果你应该生成文本或其他基于矢量的图像(然后保存为.png或.jpg),你也可以考虑开罗(在这种情况下是PyCairo)。 I use it a lot. 我经常使用它。 Otherwise, for pixel-level manipulation, PIL is the obvious choice. 否则,对于像素级操作,PIL是显而易见的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM