1
votes

I am converting PWG raster files (size in KBs) into Postscript using the colorimage command. The raster file data is being represented as hexadecimal in PS files. How ever the problem is, the generated PS files are about 500 MB in size. I want a method using which the size of these PS files will be reduced significantly without disturbing the quality of output. Sample file I have given below:

%!PS-Adobe-3.0
%%BoundingBox: 0 0 4958 7017
%Creator: Cups-Filters
%LanguageLevel: 2
%DocumentData: Clean7Bit
%EndComments
%BeginProlog
%EndProlog

%Pages: (atend)
%%Page: 1 1
%%BeginPageSetup
<< /PageSize[4958 7017] >> setpagedevice
%%EndPageSetup
gsave
gsave
4958 7017 scale
4958 7017 16 [4958 0 0 -7017 0 7017]
{currentfile 4958 string readhexstring pop} bind
false 4 colorimage

...hexadecimal information cut...

grestore
showpage
%PageTrailer
%Trailer
%%Pages: 1
%EOF

The above file is a PS representation of raster file which has CMYK color model and 16 bits for each color. The size of the raster file 278.5 KB while the above mentioned file is 563.8 MB, with 99% space occupation by the hexadecimal data.

1

1 Answers

4
votes

To add to my comments on the #ghostscript IRC channel;

First thing is to use binary instead of Hex, unless you have a good reason to want to use Hex. That will reduce the byte count by 50%.

Second thing to do is to compress the data (eg Flate) and add a FlateDecode filter to the reading code. That will reduce the size still further, how much depends on the compressibility of the data of course.

Other than that, well, image data is big, there's no real way around that.