The discussion on png format goes on for some time. A while ago I was
experimenting with dvips and ghostscript to get an optimal output from a
dvi file. It turns out that no extra utilities (like imagemagick)
niether user assisted tricks (manual copying to clipboard) are necessary
to do the job. As a matter of fact,
- dvips + ghostscript are enough to convert a dvi file
- ghostscript is enough to convert a ps file
The following batch file

@echo off
dvips -f -l=1 %1 | gswin32c -q -dBATCH -dNOPAUSE -sDEVICE=pnggray
-sOutputFile=%1.png -r96 
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -_

outputs the first page of a dvi file:
- dvips -f -l=1 %1 calls dvips and outputs only the first page (-l=1) to
a pipe (-f)
- gswin32 starts ghostscript in a quiet (-q) batch (-dBATCH) mode.
-dNOPAUSE prevents it to pause at the end of a page. -sDEVICE=pnggray
calls a ps-to-png converter. -OutputFile=%1.png gives the output file a
name. -r96 sets the resolution. -dTextAlphaBits=4 and
-dGraphicsAlphaBits=4 sets antialiasing
(necessary for a satisfactory output). The last parameter is a bit
cryptic: -_ tells ghostscript that it shoul read from the pipe.
As to the device, pnggray is one out of several available ps-to-png
converters, but after quite extensive testing I believe that it is the
optimal one for the job. The resulting files are little smaller that
gifs and have the same (if not higher) quality.

If all pages are to be converted, replace
-sOutputFile=%1.png by -sOutputFile=%1%%d.png
and a sequence of files, one for each page, will be output. The names
are <infile>1.png, <infile>2.png,<infile>3.png etc.

It is also possible to convert directly a ps file:
@echo off
gswin32c -q -dBATCH -dNOPAUSE -sDEVICE=pnggray -sOutputFile=%1%%d.png
-r96 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 %1.ps

See examples at http://mat.fsv.cvut.cz/zindulka/tex.html#music. Observe
also the technology of displaying png in browsers: One has to embed (via
<IMG> element) the png file into a simple HTML page. Otherwise a program
for which the .png extension is registered is fired.

All of the above applies to Win32 platform, but it is easy to modify it
for Linux.

Ondrej
mailto:[EMAIL PROTECTED]
http://mat.fsv.cvut.cz/zindulka
_______________________________________________
TeX-music mailing list
[EMAIL PROTECTED]
http://sunsite.dk/mailman/listinfo/tex-music

Reply via email to