问题描述
我无法将Postscript(.eps)文件转换为任何类型的图像。
每当我使用PIL保存加载的.eps文件时,它的质量都非常糟糕,并且在tkinter中呈现的文本不可读。我认为这是因为.eps文件是某种矢量图像,使用PIL保存不会呈现正确的分辨率,但是我不确定。
I'm having trouble converting a postscript (.eps) file to any kind of image.Whenever I use PIL to save the loaded .eps file the quality of it is horrible and text rendered in tkinter is unreadable. I think this is because the .eps file is some sort of vector image and saving it using PIL doesn't render the correct resolution but I'm not sure.
可以有谁知道我该如何以更高的分辨率(如果可能的话不在命令行中)保存PostScript文件,或者将tkinter画布另存为图像的任何其他方法?
Does anyone know how I could either save a PostScript file at a higher resolution (not in command line if possible) or any other methods of saving tkinter canvases as images? Any help would be greatly appreciated.
给出一些背景信息;我正在尝试制作一个使用tkinter画布并保存图像的python脚本,以便可以在浏览器中实时且在页面加载时显示该图像。
To give some context; I am trying to make a python script that takes a tkinter canvas and saves the image so that it can be displayed in a browser all in real-time and on page load.
推荐答案
1。
Ghostscript 可以做到:
gs -o output.png -sDEVICE=pngalpha input.eps
通过添加 -r ...
:
gs -o output.png -sDEVICE=pngalpha -r300 input.eps
2。
ImageMagick 也可以做到:
convert input.eps output.png
更高分辨率,添加-密度...
:
convert -density 300 input.eps output.png
但是,ImageMagick仍然会调用Ghostscript并将其用作汉的'代表'悬挂PostScript输入。可以通过在命令行中添加 -verbose
来看到。 (缺少随附的Ghostscript安装的ImageMagick安装将不适用于EPS输入文件!)
However, ImageMagick will call Ghostscript anyway, employing it as its 'delegate' for handling PostScript input. This can be seen by adding -verbose
to the command line. (An ImageMagick installation that lacks an accompanying Ghostscript installation will not work with EPS input files!)
如此好直接使用Ghostscript ...
So better go with Ghostscript directly...
这篇关于将PostScript转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!