There's a lovely little program 'dvipng' which was designed to do real-time previews of LaTeX in an editor (http://sf.net/projects/preview-latex/) but is available as a stand-alone utility as well. This can replace the dvips & convert steps of our math rendering. In theory it should be faster (I haven't benchmarked it), but the neat thing is that it can produce output with a transparent background, which has been asked for for a while.
I've been able to get pretty nice output with this command line: dvipng -q -D 120 -bg Transparent -T tight -o outputfile.png inputfile.dvi
which produces files about the same dimensions as our current stuff. They are 8-bit indexed PNG images with solid transparency, which is compatible with Internet Explorer for Windows without any hacks, and will still look nice on most light-colored backgrounds. However, they won't look too great on a dark background, and some browsers may not be able to print them correctly. There's also a truecolor option that I haven't tried (which has potential problems of its own).
Attached is a diff to render.ml which uses dvipng instead of dvips+convert. It would probably be fairly straightforward to make it a conditional option, but I don't know ocaml. ;)
dvipng requires libgd to be available.
-- brion vibber (brion @ pobox.com)
Brion Vibber wrote:
There's a lovely little program 'dvipng' which was designed to do real-time previews of LaTeX in an editor (http://sf.net/projects/preview-latex/) but is available as a stand-alone utility as well. This can replace the dvips & convert steps of our math rendering.
Thanks for the praise. The program was written for preview-latex but has gotten a growing independent audience. It is even mentioned in the TeX FAQ nowadays.
In theory it should be faster (I haven't benchmarked it), but the neat thing is that it can produce output with a transparent background, which has been asked for for a while.
In practice it is _much_ faster. You'll find that the main bottlenecks are 1) writing the image to disk, e.g., on NFS and 2) output of diagnostic messages. The -q option you use below is very helpful with the latter, writing images to a local disk with the former. On my laptop, small images take on the average 2 ms to generate, if you do a many-page DVI (=one image for each page).
I've been able to get pretty nice output with this command line: dvipng -q -D 120 -bg Transparent -T tight -o outputfile.png inputfile.dvi
which produces files about the same dimensions as our current stuff. They are 8-bit indexed PNG images with solid transparency, which is compatible with Internet Explorer for Windows without any hacks, and will still look nice on most light-colored backgrounds. However, they won't look too great on a dark background, and some browsers may not be able to print them correctly.
I find dark background and math terrible anyway. Not much I can do about this one, but I will listen to any ideas.
There's also a truecolor option that I haven't tried (which has potential problems of its own).
Such as much bigger files (and slower writing of them).
Hint: dvipng is currently in debian unstable. /JÅ
Jan-Åke Larsson wrote:
In practice it is _much_ faster. You'll find that the main bottlenecks are 1) writing the image to disk, e.g., on NFS and 2) output of diagnostic messages.
...if you are using a slow terminal (like gnome-terminal or so)...
The -q option you use below is very helpful with the latter, writing images to a local disk with the former. On my laptop, small images take on the average 2 ms to generate, if you do a many-page DVI (=one image for each page).
/JÅ
wikitech-l@lists.wikimedia.org