问题
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.
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.
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:
1.
Ghostscript can do that:
gs -o output.png -sDEVICE=pngalpha input.eps
You can get the output at a higher resolution than the default 72PPI by adding -r ...
:
gs -o output.png -sDEVICE=pngalpha -r300 input.eps
2.
ImageMagick can also do it:
convert input.eps output.png
For higher resolution, add -density ...
:
convert -density 300 input.eps output.png
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!)
So better go with Ghostscript directly...
来源:https://stackoverflow.com/questions/28856297/converting-postscript-to-an-image