![]() ![]()
|
MRG Interactive DevelopmentsMesoscale Research Group, McGill/SUNY |
The psrotate utility is a Python
program that performs basic manipulations on PostScript files. It is particularly intended
for treatment of files generated by the GEMPAK
postscript driver. The program works by directly hacking the image file itself rather than
converting image formats - this ensures that there is no loss of plot quality during the
rotation or resizing processes. psrotate can be used to
rotate images, shift an image on a page, rescale images and/or change the page size.
UPDATE - 2 April 2006: Matt Borkowski (NCSU) reported that the psrotate tool
did not work on black and white PostScript files generated by GEMPAK. This problem has been fixed, and
an updated version of the software is available for download (left shift and click for download).
psrotate runs from the command line of any machine with Python
installed. Following installation (which is as simple as downloading the program into
a directory found by the user's path - optionally the first line of the program can be edited to the correct Python
path for the local machine), the user should become familiar with the psrotate options by
running python psrotate.py -h. Note that if the correct Python path is present at the
top of the program, then simply running psrotate.py -h. From here on it will be
assumed that the path is correct - if it isn't then you will have to prepend the python command to each
of the examples below.
The only required argument is the -f FILENAME argument (it can also be written as
--file=FILENAME) that gives psrotate the name of the input PostScript
file. Optionally, a -o OUTFILE (or its long form) can be given to set the output file name.
By default, the output file is named the same as the input file with a -rot appended. All other
arguments are optional - note that it you are running psrotate on GEMPAK files,
then running with the -O 1 optimization flag is extremely beneficial.
The default operation of psrotate is to create a fitted landscape PostScript
image from the default GEMPAK rotated plot. (This rotated image can then be converted to a PNG file using
GhostScript for extremely high-quality web-ready images.) To perform
this operation, simply run psrotate.py -f INPUT.ps. The output will be generated
in INPUT.ps-rot where the value of INPUT depends
on the image file name. This file can then be converted to a high-quality PNG image using
gs -q -sDEVICE=png256 -sOutputFile=OUTPUT.ps -dNOPAUSE INPUT.ps-rot -c quit
where both INPUT and OUTPUT depend on the image
file name.
To make the PostScript image smaller without any conversions, the user might run something
like psrotate.py -f INPUT.ps -o OUTPUT.ps -s .8 -p 610x500. Note that
the page size is given in pixels and that the -O 1 option should be used if
the source file is a GEMPAK PostScript. Other rotations are also possible, for example
psrotate.py -f psc.plt -o ron.ps -O True -l 2.5 -r 20 -p 850x820
create (for whatever reason) an image rotated by 20 degrees from horizontal. The standard
Letter page size is 612x792 so this paper size should be specified
if the image is to be printed on letter-sized paper.
MRG Interactive is a supporter of open source initiatives and,
Questions or Comments? Contact our WebMaster.