nav-left cat-right
cat-right
Matthias Pospiech > Web > wikis > Converting LaTeX output into images on a webserver

Converting LaTeX output into images on a webserver

With my new website http://www.latexwiki.org I needed a way to convert the output of latex to an image in png format. Standard solutions for doing this on a webserver are the php class latexrender or the mediawiki extension wikitex. Since the wiki uses mediawiki I customised wikitex to my needs. The solutions to convert the latex output are the following
  • latex + dvipng
    dvipng creates for each page in the dvi file a new png image. This tool is used by wikitex and has the advantage of being very fast. However, it is not possible to include postscript code into the images with dvipng and thus eps images in the tex file are not converted into the png file.
    dvipng -gamma 1.5 -T tight ${HASH}
  • latex + dvips + convert
    dvips converts the dvi files to postscript files with the option E so that every page is put into a different file. This approach is used by class.latexrender.php. Afterwards the ps files can be converted with ghosscript via convert to pngs.
    PS='.ps'
    dvips -E ${HASH}.dvi -o ${HASH}.ps
    for i in ${HASH}*${PS}; do 
        convert -density 120 -trim ${i} ${i}.png
    done
  • pdflatex + pdftoppm + convert
    This approach works with pdflatex and should be much faster than using ghostscript.
    PPM='.ppm'
    pdftoppm ${HASH}.pdf ${HASH}
    for i in ${HASH}*${PPM}; do 
       convert ${i} ${i}.png
    done

Einen Kommentar schreiben

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *


*

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

WP-SpamFree by Pole Position Marketing