Re: [gnome-print] Filtering code



I'm not sure how relevant it is, but for what it is worth:

   * "convert" from the image magic suite has postscript LZW support
     that may be activated by doing:

       convert -density 72x72 -compression LZW $tiff_img_name PS2:-

     You may want to have a look at its source code for examples of
     how to do it.

  * I'm adding a small example of how to get postscript to do
    compressing that I wrote back in 1994:

        /.stdout (%stdout) (w) file def
        /encrout .stdout /ascii85encode filter /lzwencode filter def
        /encrprint { encrout exch writestring } def
        /s 1024 string def
        /encrwrite { 
            (start of encrypted code ) = 
            { 
                currentfile s readstring 
                { encrprint } { encrprint exit } ifelse 
            } loop 
            (end of encrypted code ) =
        } def

        %===============================================================
        % here write encrwrite and on the following line the postscript
        % program that you want to encrypt.
        %---------------------------------------------------------------
        encrwrite
        /helvetica findfont 24 scalefont setfont
        20 20 moveto
        (it works!) =
        (yabadabadoo!) show
        showpage

   There is a patent problem though so standard ghostscript does
   not include the /LZWEncode filter.

   To decrypt use:

        /encrin currentfile /ASCII85Decode filter /LZWDecode filter def

        %==================================================================
        % Use decrprint to decrypt and print the encrypted postscript code.
        %------------------------------------------------------------------
        /decrprint { 
            /s 1024 string def
            { 
                encrin s readstring
                { print } { print exit } ifelse 
            } loop 
        } def

        %===================================================================
        % Use decrexec to decrypt and execute the encrypted postscript code.
        %-------------------------------------------------------------------
        /decrexec { 
            { 
                encrin token 
                { exec } { exit } ifelse 
            } loop 
        } def

        %=====================================================================
        % Finally execute decrexec followed with the LZW and Ascii85 encrypted
        % program text.
        %---------------------------------------------------------------------
        decrexec
        J.'I';dn>$F>TB/+p0Qqggi2[c,W*MaCl\V_Ms:PN(u)4Nh$2<+bWlgD)]:kL@A$4
        P8$*Jc:5.-KMip6b=a/q&VS7gT,Z&HBYg@uG6JuMa)cfbc=I.\THF~>

And one more thing. Note that using these filters are really heavy
on the the CPU of old postscript printers and may cause rendering of 
big images to take several minutes... 

Hope this helps somehow.

Regards,
-- 
                                                        ___   ___
                                                      /  o  \   o \
Dov Grobgeld                                         ( o  o  ) o   |
The Weizmann Institute of Science, Israel             \  o  /o  o /
"Where the tree of wisdom carries oranges"              | |   | |
                                                       _| |_ _| |_
 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]