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

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


A circle drawn in LaTeX using TikZ:




\usepackage[active, tightpage]{preview}

\filldraw (0,0) circle [radius=3cm];

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.

  • 1
    In my case I also needed to use the -colorspace rgb to avoid errors convert RGB color space not permitted on grayscale: convert -density 300 zero.pdf -format png -colorspace rgb zero.png – tobiasBora Nov 26 '20 at 22:28

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.