Converting PostScript (ps) files is necessary sometimes, particularly if you want to produce high quality graphics for LaTeX or you have used the “print to file” option of some programs.
In Linux, the easiest way to convert this kind of files is to use the convert command, from the ImageMagick package. For example, converting a PS file to a JPEG file is as easy as typing this command in the console (assuming you have already installed the aforementioned ImageMagick package):
convert original.ps destination.jpeg
Better quality images can be generated using GhostScript (gs). For example, the same convertion produces (at least for me!) better quality jpeg images:
gs -q -dNOPAUSE -dBATCH -sDEVICE=jpeg -r300 -sPAPERSIZE=a4 \ -sOutputFile=destination.jpeg original.ps
Notice the -sDEVICE parameter, which specify which GV device we want to use and the -r300, which specify the desired resolution (in dpi). -dNOPAUSE and -dBATCH enables the command to be used inside a batch script without requiring user intervention.
They are several devices available, some of the most useful for me are:
- png16m: To convert PS files to PNG
- tiff24nc: To produce non-color tiff files, useful to directly print in several devices
- epswrite: To generate EPS files
Sometimes the original file has excessive blank space. It is possible to use the -dEPScrop option to remove the margins and try to fit the paper size to the image.
In case the file contains text, is it possible to further increase quality of the resulting file by using the -dTextAlphaBits=n (where n is 2 or 4) to apply antialiasing to the fonts.