I have a jpeg file that's 400k that I used gimp to convert to eps. The eps file is 10.8 MB. I didn't make any modifications other than cropping. Why is it so large and how do I reduce the size.
4 Answers
I would suggest using sam2p instead of the GIMP: it will convert the JPEG to EPS (and several other formats, including PDF) in a way that preserves the existing JPEG compression, which will presumably lead to less expansion as well as avoiding image degradation. (It also works on several other input formats, including PNG and GIF
Note, however, that if you are going to be converting the result into PDF at some point using Ghostscript, it will stupidly decompress the image and then (by default) recompress it using JPEG-style compression (again, by default). Whether or not Ghostscript recompresses the image, just decompressing it discards information.
If you plan to include the figure in a (La)TeX document, you should consider using pdf(La)TeX, which can include JPEG and PNG images directly (though even if it couldn't, you could use sam2p to convert the images to single-page PDF and include that instead). This will prevent any loss of image data and should use about the same size in the PDF as in the JPEG file.
JPEG is a binary format while EPS is a text format. Since it takes two hexadecimal characters to represent each byte, that alone doubles the size of your file, roughly speaking. Also, JPEG is compressed. I don't know whether the bitmap contained in the EPS file is uncompressed, but it's likely given the great difference in sizes. The difference in size between the JPEG header and the Postscript instructions is a small contributing factor.
You may find that running the following command will reduce the file size somewhat:
eps2eps inputfile.eps outputfile.eps
You will need to have Ghostscript installed in order to have the eps2eps
utility.
It's possible that ImageMagick would do a better conversion than Gimp.
convert inputfile.jpg outputfile.eps
-
The
eps2eps
command reduced a file from 10.7MB to 5.9MB for me — it seems to translate the ascii-hex image to a more compact ascii encoding.– Josh LeeDec 17, 2010 at 19:15
You don’t want to use a bitmap editor (including GIMP or ImageMagick) to convert a JPEG to EPS. The image will be decompressed and the file size will increase by an order of magnitude. It may be possible to recompress the image, but you’ll have lost quality. Unfortunately, Inkscape can’t do this either, thanks to limitations in Cairo. This Jpeg2ps tool may be of interest (though I haven’t tried it). Whatever you do, look for DCTDecode
in the EPS output.
-
"Look for DCTDecode in the EPS output." What do you mean? Should it be there, not be there, or what? Dec 5, 2012 at 17:29
-
Yes, it should; it indicates the JPEG format (Discrete Cosine Transform).– Josh LeeDec 5, 2012 at 19:08
Try shoving it through one of the ps2*
filters that comes with Ghostscript.
eps
andjpeg
??