View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

IRAF Plots to Image Formats

Mike Fitzpatrick wrote on Jun 17, 1998



> Is there a (comprehensible) way to port GRAPH output to a bitmap, .jpg,
> e.g.?  Now I'm using a screen-capture utility-surely there is a better
> way.  I've discovered that I can export to .eps but don't know of a
> utility which converts this properly-text, especially, seems to suffer
> considerably from the translation.

	The output from iraf graphics is normally some sort of plotter
language (e.g. Postscript), but as long as you've got some way to convert
that to another format it's possible to write a graphcap entry to create 
the new format automatically.  For converting Postscript files two poss-
ibilities are the 'gs' task as part of Ghostview (but you sometimes need
to configure the output formats specially when building it), or the
'convert' task in the ImageMagick package (available from most X mirror
sites, e.g. ftp://ftp.x.org/contrib/applications/ImageMagick).  For example,
the following entry creates a device name 'gif-dump' that create a 640x480
GIF image called 'irafXXX.gif' in the current directory (where XXX is a 
process id) using the convert program:

gif-dump|UNIX generic interface to GIF file dump:\
        :DD=psdump,tmp$sgk,!{ sgidispatch sgi2uapl -t $F -l$(XO) -w$(XW) \
        -b$(YO) -h$(YW) -p$(PW) > /tmp/irafdmp$$.ps ; \
        convert /tmp/irafdmp$$.ps -geometry 480x640! iraf$$.gif ; \
        rm $F /tmp/irafdmp$$.ps; }&:tc=sgi_apl:

The '-geometry' flag fixes the image size, there are other options to this
task you may want to add as well.  The '-t' flag to the sgi2uapl translator
is needed to keep the small timestamp from appearing on the page.  To use
this entry you would do the following:

    cl> copy dev$graphcap home$mygraphcap	# make a private graphcap
    cl> edit home$mygraphcap
	....add the above entry to the file
    cl> reset graphcap = home$mygraphca		# declare it
    cl> gflush					# reinitialize

Then use either ":.snap gif-dump" in a cursor mode to make the image, or
something like

	cl> contour dev$pix dev=gif-dump ; gflush

to make it in batch mode, the 'gflush' is needed to flush the graphics
buffer right away.  If you need help tweaking this to get it to do exactly
what you want let me know,  the actual conversion task you use is up to
you but it will have to be installed separately.
	There's no real general way to workaround the text conversion prob-
lem.  It is caused by the fact that the postscript file is written assuming 
a page resolution on order 3300x2500, but you're converting this to a smaller
image of say 640x480.  The individual strokes in the character drawing get
lost in the lower resolution and the text quality degrades.  Using the 
'convert' task does about as well as any other at this, but it has a
'-density' option you can use to increase the resolution but also the size
of the image (the defaults is 72 dpi which corresponds to normal screen
resolution which is why the GIF image looks the same on the screen as when
previewing the postscript file directly, normal page resolution is 300dpi).
	The other drawback to this method is that the SGI translators won't
preserve any color info you may see in an XGterm window.  You can use the
STSDAS Postscript kernel and another modification to the graphcap to work
around this but it won't help the text presentation.  If what you're after
is a nice image of a plot window then using a screen capture tool like
'snapshot' on Suns or 'xwd' elsewhere will preserve the colors and the image
appears as it does on the screen.  The text isn't degraded in this case
because the plot is normally drawn using a screen font and not with the
stroke data used for hardcopy in the SGI kernel.

Mike Fitzpatrick

Last post on Jun 17, 1998