# Converting eps to png - dimensions [closed]

When I convert EPS to PNG using this command

gs -dSAFER -dBATCH -dNOPAUSE -r600 -sDEVICE=pnggray -sOutputFile=%1.png "%1.eps"

I get PNG picture with large dimensions, although the bounding box in EPS is correct.

For example from EPS with header

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 204 603 407 759
%%HiResBoundingBox: 204.242619 603.788607 406.691988 758.249977
%.................................
%%Creator: GPL Ghostscript 864 (epswrite)
%%CreationDate: 2011/12/10 21:30:18
%%DocumentData: Clean7Bit
%%LanguageLevel: 2


I've obtained a 4958x7018 png. This would correspond to the whole A4 page and not to the bounding box.

Here's the link to png file: http://i.stack.imgur.com/i5joS.png (I did not want to put the huge monstrosity into the post) and the screenshot from gsview showing the bounding box: http://i.stack.imgur.com/BrJx3.png ; I also uploaded the EPS file to rapidshare - I am not sure what is the preferred way for sharing files here. (The file is here just for the case that the problem description is not clear enough.)

I usually draw my pictures in metapost, from which I easily get EPS and PDF - which are ideal for inclusion into my TeX documents. The reason I needed conversion to some different format was that I wanted to post the picture at math.SE. It is possible to upload pdf on imgur, but the result is very ugly.

My questions:

• Is there a way to get PNG with dimensions corresponding to bounding box?

• Any other suggestions for converting EPS to PNG using ghostscript? (Are there some more parameters I should have used?)

-

## closed as off topic by Werner, Joseph Wright♦Dec 11 '11 at 8:21

Questions on TeX - LaTeX Stack Exchange are expected to relate to TeX, LaTeX or related typesetting systems within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

I don't think this is on-topic for this Q&A... –  Werner Dec 11 '11 at 7:47
Just in case someone, who also tries to convert eps to png, stumbles upon this question; I will say that recently I have started using online-convert.com for this and so far I am satisfied with the results. –  Martin Apr 26 '14 at 11:10

You need to also use the -dEPScrop option. From the GhostScript "How to use" page:

### EPS parameters

-dEPSCrop Crop an EPS file to the bounding box. This is useful when converting an EPS file to a bitmap.

-dEPSFitPage Resize an EPS file to fit the page. This is useful for enlarging an EPS file to fit the paper size when printing.

-dNOEPS Prevent special processing of EPS files. This is useful when EPS files have incorrect Document Structuring Convention comments.

-
Thanks a lot. It worked. (I should have noticed this. I somehow concentrated only on occurrences of the word "png" in that document.) –  Martin Dec 11 '11 at 7:51

try adding -dEPSCrop to gs

OR

Why don't you try convert from Imagemagick? You're likely to find that standard on most Linux platforms. I believe there are geometry options to the conversions.

-
Thanks a lot. I work on Windows, so I would have to install Imagemagick. (But I probably should, it seems to be useful program.) But since I found out gs is capable of doing this, I wanted to try this possibility, too. –  Martin Dec 11 '11 at 7:49
Then use the cygwin Imagemagick setup, it's easier to manage and setup. –  Sivaram Dec 11 '11 at 8:06