Menu

LaTeX document to XPM

← TOC    ↑ Home    LaTeX document PDF EPS SVG PNG JPEG ICO XPM

LaTeX document to XPM

This page shows how to convert a LaTeX document x.tex into an XPM image.

When converting vector graphics to bitmap images (like XPM) you have to specify a resolution. This is the number of pixels per inch.

To create a toolbar button image, prepare the image as 1 inch (width) × 15/16 inch (height) rectangle and use a resolution of 16.


Choice 1: Use gxhconvert

Procedure

gxhconvert -o=xpm -r=16 x.tex

See the [gxhconvert manual] for a full description of the gxhconvert script.

Options

Option Purpose
-r=... Resolution in dpi (dots per inch).
-a
--alpha
Create alpha channel. Untouched input regions result in transparent output regions.

Choice 2: Manual conversion, create alpha channel

Step 1: Create PDF

pdflatex -interaction=nonstopmode x

Step 2: Convert PDF to SVG

pdf2svg x.pdf x.svg

Step 3: Create 32 bit color PNG file

inkscape --batch-process --export-type=png --export-overwrite --export-filename=x-16.png --export-dpi=_resolution_ --export-area-page x.svg

Step 4: Create alpha PAM file

pngtopam -alpha x-16.png > x-16.pgm

Step 5: Create XPM file

pngtopam -mix x-16.png | pnmquant 16 | ppmtoxpm -name _name_ -hexonly -alphamask=x-16.pgm > x.xpm

The name argument in the ppmtoxpm command must be a valid
identifier (variable name) in the C programming languange.

Step 6: Correct XPM file

Replace "static char" by "static const char" at the start of the file.

Temporary files

  • x-i.pdf
  • x.pdf
  • x.svg
  • x-16.png
  • x-16.pam

Choice 3: Manual conversion, do not create alpha channel

Step 1: Create PDF

pdflatex -interaction=nonstopmode x

Step 2: Produce XPM

pdftoppm -r 16 x.pdf | pnmquant 16 | ppmtoxpm -name <i>name</i> -hexonly &gt; x.xpm

The name argument in the ppmtoxpm command must be a valid
identifier (variable name) in the C programming languange.

Step 3: Correct XPM file

Replace "static char" by "static const char" at the start of the file.

Temporary files

  • x.pdf
← TOC    ↑ Home    LaTeX document PDF EPS SVG PNG JPEG ICO XPM

Related

Wiki: gxhconvert manual