How can I generate GIFs from my ABC files on Win95/98/NT?

Abc2ps can output either a single multipage ps file (generally with multiple tunes per page) or multiple eps files (one file per tune, where the size of the eps image depends on the length of the typeset tune).

In order to batch process files and avoid editing the images by hand, you want to set abc2ps to output eps files. You should also define a format file (or use metacomments in your abc file) to set the margins to zero and the width of the staff narrow enough for your web pages (something like 250 points).

You can use ghostscript from the command-line to convert the eps file to a bmp, tiff, or other raster image. For example:
  gswin32c -q -dNOPROMPT -dBATCH -sDEVICE=bmpmono -r72 -sOutputFile=myImage.bmp myImage.eps
See below for details on the syntax. Unfortunately, I haven't been able to figure out how to tell ghostscript to clip the image to the bounding box defined in the eps image file. I use GSview to work around that. It's not a batch process, but it doesn't involve any image editing.

I convert eps files to gif using GSview and PhotoEditor (which comes with MS Office) as follows:

As for other free command-line image conversion programs that can batch process files, you're probably out of luck. Most of the programs that created GIF files disappeared when Unisys, the owner of the LZW compression patent, began enforcing licence fees.


Fixing the bounding box problem

A brute force fix for the bounding box problem would be to modify abc2ps to offset the image so that the lower left corner of the image is at the origin (the lower left corner of a full 8.5x11" page for the coordinates used by abc2ps) instead of centered at the top of the page. This would allow the use of the ghostscript option -gNNNxMMM to clip the output image to a NNN point by MMM point rectangle with the lower left corner at the origin.

A better fix would be to add a command-line option to ghostscript to change the lower left clipping point as well as the upper right clipping point.

For both of these fixes, you need to look at the EPS header to get the values for the clip points. Or write a script to automatically extract them and call GS with the correct clipping values.

The best fix would be to add a command-line option to ghostscript to get the clipping points from the EPS bounding box. That's what the bounding box is for anyway.


Here is some relevant documentation from ghostscript manual

gs5man-e.pdf section 3.3 says:

In addition to the file format drivers listed in the table below, previous Ghostscript versions contained one for the GIF graph- ics file format. In reaction to the licensing problems around the LZW compression technique used in GIF, Peter Deutsch dropped support for this format from the Ghostscript distribu- tion. If you have to create GIF files you can integrate the GIF driver from an older release. However, it’s easier to render to another graphics file format (e. g., TIFF or PNG) and convert it to GIF using a graphics converter.

The tables on the next pages list all display, printer, and file format drivers available for Ghostscript 5.01. Each line contains a description of the device or format and the short name of the driver. The last column in the table tells you on which of the fol- lowing platforms the particular driver is part of the standard configuration:

Fax and other raster file format drivers in Ghostscript 5.01

gs5man-e.pdf section 6.1 says:

Converting PostScript to raster graphics formats.

Several file format drivers enable Ghostscript to convert Post- Script files to TIFF, PBM, PCX, BMP, etc., given the appropriate driver has been compiled into the Ghostscript executable. The Ghostscript call contains the name of the driver and (optionally) the resolution. For example, to create a 600 dpi bitmapped TIFF version of a file, use the following command:
     gs -q -dNOPROMPT -dBATCH -sDEVICE=tiffpack -r600 -sOutputFile=page%d.tif file.ps Ghostscripts replaces the "%d" variable in the filename with the actual page number (page1.tif , page2.tif etc.). By default, the TIFF drivers use a resolution of 204x196 dpi (standard fax resolu- tion).

gs5man-e.pdf section 5.1 says:

-q
(quiet) Suppress normal startup messages.

-dNOPROMPT
Disables the prompt (but not the pause) at the end of each page. This prevents text and graphics output from being mixed on PC displays.

-dBATCH
Instead of displaying the interactive prompt after processing all command line files, Ghostscript exits. Equivalent to "-c quit .".

-sDEVICE=<device>
Select the initial output device driver.

-r<number>
-r<number1>x<number2>
Equivalent to -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLUTION=number2 (see below). This is intended for devices that support different horizontal and vertical resolu- tions, especially dot matrix printers.

-dDEVICEXRESOLUTION=<number>
-dDEVICEYRESOLUTION=<number>
Sets the device horizontal resp. vertical device resolution in dpi.

-sOutputFile=<filename>
Selects an output file name or pipe. If the file name contains the characters "%d", Ghostscript replaces the "%d" with the actual page number and creates one file for each page, e. g., page%d.prn yields page1.prn , page2.prn and so on. On OS/2, Windows 95 and Windows NT you can use printer queue names: -sOutputFile="\\spool\printername" sends the output to the named printer queue. If the printer name is missing, Ghostscript prompts for the name of the (connected) printer (Windows) or uses the default queue (OS/2). On Unix, you can also redirect the output to another pro- gram via pipe: -sOutputFile=\|lp . The special name "-" for the output file instructs Ghostscript to send the data to its standard output.


Eric M. Mrozek (mrozek@umich.edu), EECS-Systems, University of Michigan
Note: I, Eric Mrozek, am not the author of abc2ps or abcm2ps.

Last Update: 15 October 2000

Return to Eric Mrozek's Home Page.