5

I have a T-shirt I designed in LaTeX, and now I need to convert the LaTeX to a white-foreground transparent-background image. How can I do that easily?

  • 3
    If you want help on this, you're going to have to give us more on this than a general description. What tools you used (TikZ, pstricks, something else) may or may not be determinants in how easy it is to achieve the effect you want. By posting a MWE, you will greatly help us understand better how to make suggestions and you will more likely get a response. – A.Ellett Jul 13 '14 at 14:57
10

You have multiple options to create a Scalable Vector Graphics (SVG) image, or a raster Portable Network Graphics (PNG) file from the compiled PDF.

For creating an SVG from the PDF file I'd recommend using Inkcscape since it is a multiplatform application which runs on Linux, Windows and OS X. For creating a raster PNG I'd recommend using Gimp, which is also multiplatform. You can import the PDF into these applications and either save them into SVG or PNG. In case you have drawn everything in your design with black, then you'll have to invert the colors of the imported PDF in Gimp, or change the fill and stroke colors to white in Inkscape.

There are several command-line tools what you can use to achieve the same thing. One of them is ImageMagick (also multiplatform) which you can use to create a PNG from your PDF directly, also inverting the colors in one single step:

convert -density 100 input.pdf -negate -format png output.png

You can play with the density command-line option to get a higher resolution PNG image.

This option specifies the image resolution to store while encoding a raster image or the canvas resolution while rendering (reading) vector formats such as Postscript, PDF, WMF, and SVG into a raster image. Image resolution provides the unit of measure to apply when rendering to an output device or raster image. The default unit of measure is in dots per inch (DPI). The -units option may be used to select dots per centimeter instead.

[…]

— ImageMagick: Command-line Options


Example

A circle drawn in LaTeX using TikZ:

\documentclass[10pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tikz}

\usepackage[active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}

\begin{document}
\begin{tikzpicture}
\filldraw (0,0) circle [radius=3cm];
\end{tikzpicture}
\end{document}

Converting it to a raster white circle using ImageMagick:

convert -density 100 example.pdf -negate -format png output.png

Transparency was retained while the black color was inverted to white thanks to the -negate option.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.