groff
[Top][All Lists]
Advanced

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

Re: [Groff] groff Image Formats


From: Larry Kollar
Subject: Re: [Groff] groff Image Formats
Date: Tue, 16 Oct 2007 21:41:54 -0400

Frank Jahnke wrote:

What image formats can be used with groff?  To date, I have used
encapsulated Postscript (.eps) and PSPIC with the -ms macro package, but
I am having increasing difficulty doing the conversion of some complex
images to eps.  Are there alternatives that can be used,
like .png, .ps, .jpg or others?

As far as I've been able to tell, all graphics are either EPS or (in the case of -mwww's .PIMG macro) become EPS. I'd love to find out different though!

I wrote a shell script to convert PNG files to EPS. This version uses "sips" (an OSX-specific image processing program) to determine image width, but could be modified easily enough to use PBMtools or ImageMagick.

------------------begin------------------
#! /bin/sh

for i in $@ ; {

        fn=`basename $i .png`

        sips -g all $i | awk -v fn=$i -v ff=$fn '

# we dont need all these props, but keep them for future reference
                /pixelHeight/ { dh = $2; }
                /pixelWidth/  { dw = $2; }
                /dpiHeight/   { rh = $2; }
                /dpiWidth/    { rw = $2; }

                END {
                        # set DPI to fit in 4.75i
scale = 0.06; # 1200 dpi
                        if( dw <= 4275 ) scale = 0.08;  #  900 dpi
                        if( dw <= 2850 ) scale = 0.12;  #  600 dpi
                        if( dw <= 2137 ) scale = 0.16;  #  450 dpi
                        if( dw <= 1425 ) scale = 0.24;  #  300 dpi
                        if( dw <= 950 )  scale = 0.36;  #  200 dpi
                        if( dw <= 713 )  scale = 0.48;  #  150 dpi
                        if( dw <= 475 )  scale = 0.72;  #  100 dpi
                        if( dw <= 342 )  scale = 1.0;   #   72 dpi

cmd = "pngtopnm " fn " | pnmtops -noturn - scale=" scale " >" ff ".eps";
                        print cmd;
                        system( cmd );
                }
                '
}
-----------------end-----------------

-- Larry





reply via email to

[Prev in Thread] Current Thread [Next in Thread]