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?
[Tex/LaTex] Generating a transparent image from LaTeX
conversionpngtransparency
conversionpngtransparency
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?
Best Answer
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:
You can play with the density command-line option to get a higher resolution PNG image.
— ImageMagick: Command-line Options
Example
A circle drawn in LaTeX using TikZ:
Converting it to a raster white circle using ImageMagick:
Transparency was retained while the black color was inverted to white thanks to the
-negate
option.