Re: Generating PNG or JPG ?
by Kjell Magne Fauske Mar 23, 2007; 02:47am
On 3/22/07, Hari Sundarwrote:
> Hi,
>
> Is it possible to generate images from tikz code ? I would like to put these
> images on a webpage and was wondering if there is an automatic way of
> generating the images rather than taking screenshots.
>
Sure, I do it every time I update the gallery I maintain at
http://www.fauskes.net/pgftikzexamples/
My approach is to use Ghostscript. Lets say I have a tex file named
figure.tex The work flow is approximately like this:
> pdflatex figure.tex
I then run ghostscript on the generated file figure.pdf to generate a PNG:
> gs -dNOPAUSE -r400 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sDEVICE=png16m -sOutputFile=figure.png -dBATCH figure.pdf
(On Windows the command is gswin32c. )
>From the resulting PNG file I generate a jpg thumbnail.
To crop the figures I use a package called preview[1]. The package
provides several ways of previewing parts of your document. For
example, adding this to your document preamble:
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
will extract every tikzpicture environment. If you use pdflatex, every
tikzpicture will be put on a separate page in the resulting pdf
document. To add a margin around the figure add:
\setlength\PreviewBorder{10pt}%
[1] http://www.ctan.org/tex-archive/help/Catalogue/entries/preview.html
Regards,
Kjell Magne Fauske
研究生们总在某个阶段脑筋就会有点不正常。Because all research students are insane at one time or another.
Wednesday, July 4, 2007
Generating JPGs and PNGs from Tikz/PGF
Gem of a post found at Nabble.com:
1 comment:
Oi, achei teu blog pelo google tá bem interessante gostei desse post. Quando der dá uma passada pelo meu blog, é sobre camisetas personalizadas, mostra passo a passo como criar uma camiseta personalizada bem maneira. Se você quiser linkar meu blog no seu eu ficaria agradecido, até mais e sucesso. (If you speak English can see the version in English of the Camiseta Personalizada. If he will be possible add my blog in your blogroll I thankful, bye friend).
Post a Comment