简体   繁体   English

如何保存Pymaging PNG图像?

[英]How to save a Pymaging PNG image?

I'm trying to test out the new pure-python imaging library called Pymaging . 我正在尝试测试名为Pymaging的新纯Python映像库。

Although it seems to be really well documented, I can't find any examples at all. 尽管它似乎确实有据可查,但我根本找不到任何示例。 I got as far as creating a new image with a background color, but when I try to save the blank image to a png image it says it doesn't support the format: 我可以创建具有背景色的新图像,但是当我尝试将空白图像保存为png图像时,它说它不支持该格式:

Traceback (most recent call last):
  File "C:\Users\BIGKIMO\Desktop\pymagingtest.py", line 6, in <module>
    img.save_to_path(r"C:\Users\BIGKIMO\Desktop\pymagingtest.png")
  File "C:\Users\BIGKIMO\Desktop\vshapes\thirdparty\pymaging\image.py", line 105, in save_to_path
    self.save(fobj, format)
  File "C:\Users\BIGKIMO\Desktop\vshapes\thirdparty\pymaging\image.py", line 98, in save
    raise FormatNotSupported(format)
FormatNotSupported: png

This is odd, because the docs say that PNG images are supported, and I even have the pymaging_png module (this is also not clear from the docs, not sure if one has to get those image format modules for each image format one wants to deal with?). 这很奇怪,因为文档说支持PNG图像,而且我什至有pymaging_png模块(文档中也不清楚,不确定是否必须为每个要处理的图像格式获取那些图像格式模块)用?)。 I also thought it might be the distribute module dependency but I also installed that and still getting same error. 我还认为这可能是分发模块依赖性,但我也安装了该依赖性,并且仍然遇到相同的错误。

If it matters, I haven't actually installed the Pymaging module, but that shouldn't be strictly necessary since it is pure python, I just append its folder to the sys.path and import from there. 如果有关系,我实际上没有安装Pymaging模块,但是由于它是纯python,因此不一定严格必须安装,我只是将其文件夹附加到sys.path并从那里导入。 Oh and I'm using Python 2.7 on a Windows 7 operating system. 哦,我在Windows 7操作系统上使用Python 2.7。

My code is below: 我的代码如下:

import sys
sys.path.append(r"C:\Users\BIGKIMO\Desktop\vshapes\thirdparty")
import pymaging

img = pymaging.image.Image.new(pymaging.colors.RGBA, 1000,500, pymaging.colors.Color(22,22,222,0))
img.save_to_path(r"C:\Users\BIGKIMO\Desktop\pymagingtest.png")

Creator of Pymaging here. 这里的Pymaging的创建者。 Thank you for your interest in this package. 多谢您对此套件的关注。

Unfortunately, Pymaging is still very much in an experimental stage, and not at all ready for production. 不幸的是,Pymaging仍处于试验阶段,还没有准备好投入生产。 This is also why it has a distinct lack of end-user documentation. 这也是为什么它缺少最终用户文档的原因。 I'm a strong proponent of documenting code, so by not documenting this package, I want to indicate that it's not ready. 我强烈建议编写代码,因此通过编写此程序包,我想表明它尚未准备好。 This is why there's a lot more documentation about the internals, to make it easier for others to hack on this project. 这就是为什么有很多关于内部的文档的原因,以使其他人更容易破解该项目。

Having said that, the PNG module should actually work. 话虽如此,PNG模块实际上应该可以工作。 However your issue is most likely due to the fact that you don't have pymaging-png [1] installed. 但是,您的问题很可能是由于您没有安装pymaging-png [1]而引起的。 The main Pymaging package does not actually provide any format support by design, de-coupling the format release cycle and development from the main package. 主要的Pymaging软件包实际上并未通过设计提供任何格式支持,从而使格式发布周期和开发与主要软件包脱钩。 This means that just installing Pymaging will have the arguably unexpected result of not having a working install at all. 这意味着仅安装Pymaging可能会导致根本没有有效安装的意外结果。

[1] https://github.com/ojii/pymaging-png [1] https://github.com/ojii/pymaging-png

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

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