shellarguments % push command line arguments to stack /tmpstr 65535 string def % define temp buffer /outstreamRaw % define raw output stream / file with filters (new file) 2 index (w) file def /outstreamRawAppend % define raw output stream / file with filters (append) 2 index (a) file def /instream % define inputstream / file 3 index (r) file def /decodeFilters % decode filters 4 index def /outstreamEncode % define output stream / file with filters 2 index (a) file 6 index cvx exec def /compress { (%!\ncurrentfile) outstreamRaw exch writestring % header, no filers for header decodeFilters outstreamRaw exch writestring % header ( cvx exec\n) outstreamRaw exch writestring % header outstreamRaw closefile { instream tmpstr readstring not { outstreamEncode exch writestring exit } if outstreamEncode exch writestring } loop outstreamEncode closefile instream closefile flush (~>) outstreamRawAppend exch writestring % End outstreamRawAppend closefile } bind def compress