Maybe a vectorial format is better suited for your needs, but is hard to tell without having a concrete example of what you'd like to get.
For example, if the images are all alike, you could create a SVG base image with Inkscape, then edit it programmaticaly from Python or Ruby (either by editing the text or using a XML library) and finally export it to PNG.
Update: After seeing the example image, I think SVG would be the most convenient choice. A SVG image is an XML file that basically says "draw a circle from here to here, write the string '13º52' there", etc. You could draw a unique base chart in Inkscape and have your program just adding the lines and symbols for each case. Finally you export to PNG.
The advantages are: easier for you to draw, the image is fully scalable, you can change the styling just by editing a property ("make all lines wider", "change all text to Arial", "paint the background blue"), you can export to any format without losing quality, and I think it's more mantainable.
In Python, you'd typically use PIL, the Python Image Library. I've never used PIL for anything beyond the simplest tasks, so I can't say how well it performs in practice.
For Python I the most common choice for image formats is PIL and then Pycairo for vector formats. The two can work together, for exadmple in this cookbook entry to use PIL images for Pycairo surfaces.
发布评论
评论(6)
也许矢量格式更适合您的需求,但如果没有您想要获得的具体示例,则很难判断。
例如,如果图像都很相似,您可以使用 Inkscape 创建 SVG 基本图像,然后从 Python 或 Ruby 以编程方式对其进行编辑(通过编辑文本或使用 XML 库),最后将其导出为 PNG。
更新:
看到示例图像后,我认为 SVG 将是最方便的选择。 SVG 图像是一个 XML 文件,基本上是“从这里到这里画一个圆,在那里写下字符串‘13°52’”等等。您可以在 Inkscape 中绘制一个独特的基本图表,并让您的程序只需添加以下线条和符号:每个案例。 最后导出为 PNG。
优点是:更容易绘制,图像完全可缩放,只需编辑属性即可更改样式(“使所有线条更宽”,“将所有文本更改为 Arial”,“将背景绘制为蓝色”),您可以导出为任何格式而不会损失质量,而且我认为它更易于维护。
Maybe a vectorial format is better suited for your needs, but is hard to tell without having a concrete example of what you'd like to get.
For example, if the images are all alike, you could create a SVG base image with Inkscape, then edit it programmaticaly from Python or Ruby (either by editing the text or using a XML library) and finally export it to PNG.
Update:
After seeing the example image, I think SVG would be the most convenient choice. A SVG image is an XML file that basically says "draw a circle from here to here, write the string '13º52' there", etc. You could draw a unique base chart in Inkscape and have your program just adding the lines and symbols for each case. Finally you export to PNG.
The advantages are: easier for you to draw, the image is fully scalable, you can change the styling just by editing a property ("make all lines wider", "change all text to Arial", "paint the background blue"), you can export to any format without losing quality, and I think it's more mantainable.
在 Python 中,您通常会使用 PIL(Python 图像库)。 除了最简单的任务之外,我从未使用过 PIL 来执行任何其他任务,因此我无法说它在实践中的表现如何。
我会通过查看其文档开始深入研究 PIL,特别是 绘图模块的文档。
In Python, you'd typically use PIL, the Python Image Library. I've never used PIL for anything beyond the simplest tasks, so I can't say how well it performs in practice.
I'd start digging into PIL with a look at its documentation, particularly the documentation for the draw module.
当我处在你的处境时,我发现 Gruff 很容易使用。
无耻的博客插件。
I found Gruff easy to use when I was in your shoes.
Shameless blog plug.
对于Python,我最常见的图像格式选择是PIL,然后是矢量格式的Pycairo。 两者可以一起工作,例如在本食谱条目中对 Pycairo 表面使用 PIL 图像。
For Python I the most common choice for image formats is PIL and then Pycairo for vector formats. The two can work together, for exadmple in this cookbook entry to use PIL images for Pycairo surfaces.
查看 Ruby-GD2 或 ImageMagick 或 GraphicsMagick 绑定。
Look at Ruby-GD2 or an ImageMagick or GraphicsMagick binding.
当我在做 python chalange (http://www.pythonchallenge.com/) 时,我使用了 Python图像库 (http://www.pythonware.com/library/pil/)
when I was doing python chalange (http://www.pythonchallenge.com/) I've used Python Image Library (http://www.pythonware.com/library/pil/)