Reputation: 77
I would like to have some help to improve the compression of an .eps file with ghostscript.
So far I use the fonction eps2write:
-sDEVICE=eps2write -r72 -dLanguageLevel=1 -sOutputFile="%HOMEDRIVE%%HOMEPATH%\Desktop\cleaned.eps" -dNOPAUSE -dEPSCrop %1 -c quit pause
If I use a 18Mo file that I get from Matlab it compresses it to 13Mo. Unfortunately it is still too big to be opened in Illustrator. Any tips would be very welcomed.
Upvotes: 0
Views: 390
Reputation: 1
If you are compressing eps files that contains image, try ColorImageResolution with DownsampleColorImages.
This command works for me:
gs -o outputfile.eps -sDEVICE=eps2write -dDownsampleColorImages=true -dColorImageResolution=300 inputfile.eps
Adjust dColorImageResolution = <resolution>
on your demand. 300 is good enough for printing documents.
Upvotes: 0
Reputation: 31199
OK first off you aren't 'compressing' your EPS program, you are creating a brand new EPS program which should be visually the same. Its a subtle distinction, but its important. This is documented here.
Without seeing your EPS program its impossible to know why its so large, the likelihood is that it contains a large bitmap image, but there may be other reasons. Without knowing why the file is large, and what compromises in quality you are prepared to accept, its impossible to make recommendations for reducing it.
Your command line does nothing which I would expect to result in a reduced file size.
Setting LanguageLevel=1 does nothing, because you are using eps2write which always writes level 2 output. If it did do anything it would likely make the file bigger because of all the language level 2 constructs that would have to be rewritten using level 2 operators.
Setting the resolution to 72 does nothing in general, because eps2write (and the related family of devices) strive hard to retain the device and resolution-independent nature of the input. The onl;y time the resolution is used is when the input uses some primitive which cannot be reproduced in the output, and the primitive is rendered to an image. If that was happening I think you would be horrified by the extremely low resolution result.
If you want to produce a new file, which trades quality for file size, then you need to look at the various options described in the documentation.
There are a few things which might reduce the file size, at the expense of quality, in particular the image downsampling parameters. Its up to you to decide just how much quality you are prepared to trade for file size, so you will have to decide what level to set these parameters to.
Its also entirely possible that the program is simply very complex (lots of long paths for example) and cannot be significantly reduced. PostScript is not intended as an editable container format and Illustrator is not intended as a graphical PostScript editor, if you want to modify the content, go back to Matlab, modify the document and recreate the EPS file.
Upvotes: 1