I have this eps image named "input.eps".
I run the following command on it:
gs -dNOPAUSE -dBATCH -q -sDEVICE=ps2write -sOutputFile=output.eps input.eps
The resulting output file "output.eps" has the right side of the figure chopped off. Why?
Note: The reason I'm using GhostScript is to change the fonts in the input.eps file, which I'll do by specifying the -I
switch with the path to the fonts. I haven't put that in the code snippet as it is not relevant to the issue.
EPS files do not request a media size (they are intended for inclusion in a PostScript program by applications). So, if you don't tell Ghostscript what size media to use it has no choice but to use its default.
Depending on your operating system (and locale if appropriate), this is likely to be either Letter (612 by 792 units) or A4 (596 by 842 units). Your EPS file claims it has a Bounding Box of 1008 units by 504 units.
So clearly your EPS won't fit across the media, and will therefore be cropped.
You can either wrap the EPS up as is normal for inclusion in a PostScript program, and request the media there, or you can use the -dEPSCrop switch which reads the Bounding Box from the comments and uses that for a media request.
Note that, despite the existence of the BoundingBox, this is not technically a valid EPS file. It has the wrong DSC identifier and executes showpage.
As a final note, you won't be 'changing' the fonts in the EPS file, as the EPS file does not contain any fonts, just references to font names.