add tag
> *Background story: As I recently needed to replace my goto tool `sips` because of a bug in macOS 13, I thought I'd post the results of my tests here in case others face a similar problem*

Let's assume one has a TikZ drawing with pattern, shadings and transparency. Which tools can be used to convert the resulting PDF to PNG?

Test file:



  bounding box={(-2pt,-2pt) and (2pt,2pt)},
  tile size={(\tikztilesize,\tikztilesize)},
  tile transformation={rotate=\tikzstarrotate},
    points/.store in=\tikzstarpoints,points=5,
    radius/.store in=\tikzstarradius,radius=1pt,
    rotate/.store in=\tikzstarrotate,rotate=0,
    tile size/.store in=\tikztilesize,tile size=3pt,
}, code={
    \fill (90:\tikzstarradius) \foreach \i in {1,...,\tikzstarpoints}{
      -- (90+2*\i*\a-\a:\tikzstarradius/2) -- (90+2*\i*\a:\tikzstarradius)
    } -- cycle;
} }

	% wing
	\path (0.1,0.1) rectangle (2.1,2.4);
		\shade[bottom color=yellow!70!brown, top color=green!40!teal] \duckpathcrazyhair;
		\path[pattern=myStars,pattern color=blue] \duckpathtshirt;
  \fill[red,opacity=0.3] (0,0) circle [radius=1cm];
Top Answer
# xpdf
pdftopng -r 150 -alpha document.pdf test_xpdf

- transparent background
- shading works fine
- the pattern is visible, although a tiny bit shifted to what my pdf viewer would show me (no idea which of both is right...)

# ImageMagick
convert +antialias -interpolate Nearest -density 1000 -resample 150 document.pdf test_imagemagick.png

- transparent background
- shading works fine
- pattern looks the same as in pdf viewer
- memory usage can be pretty high if the pdf has many pages. It seems that first all pdf pages are read in and at the end all pngs are created. This is what I currently use for smaller documents.

#  inkscape
inkscape --export-type=png --export-filename=test_inkscape --export-overwrite   --export-dpi=150 document.pdf

- transparent background
- shading missing
- pattern in wrong size

(... but there are a lot of options, maybe I did not look hard enough to find the holy grail...)

# poppler
pdftoppm -png -r 150 document.pdf test_poppler


- no transparent background
- shading works fine
- pattern looks the same as in my pdf viewer
- memory usage seems to be lower for multi-page pdfs compared to ImageMagick, each page seems to be processed after another. This is what I use to convert the pdfs of the Xmas extravaganzas to png.

# MacOS

Honorary mention. On previous versions of macOS, one could use  
sips -s format png document.pdf --out test_mac.png
Sadly, this throws an error on the current version macOS 13.3.1.

- transparent background
- problems with shading
- problems with pattern
Answer #2
# Cairo (poppler-cairo to be precise[^1])

pdftocairo -png -r 150 document.pdf test_cairo


For transparent background:

pdftocairo -png -r 150 -transp document.pdf test_cairo


(Comparing with Zathura with MuPDF-backend as PDF-viewer):

- the colours seem a bit more saturated/darker without the transparent background

- transparency works fine (option for transparent background for PNG and TIFF files)

- pattern looks fine

- multiple pages supported, no idea about performance/memory usage

[^1]: `pdftoppm` uses poppler-splash, see

# MuTool (part of MuPDF)

There are two subcommands that lead to slightly different results

1. `mutool draw`
    mutool draw -o test_mupdf_draw.png -c rgba -r 150 document.pdf
    - transparent background (don't forget `rgba`, without it you don't get transparent backgrounds)
    - shading works
    - pattern supported (looks like in my MuPDF-based PDF-viewer... took a close look at 600dpi resolution, on low resolutions the pattern placement looks off)

2. `mutool convert`
    mutool convert -o test_mupdf_convert.png -O resolution=150,alpha document.pdf
    - transparent background (thanks to the `alpha` key)
    - shading works
    - pattern placed slightly off, it seems (took a close look at 600dpi resolution, worse on low resolutions)
    - silently appends page number if you omit `%d` in the output file name to support multi-page documents (even if the document is single page)

For both the manpage in Arch Linux is incomplete (found the `alpha` key by the error message when I input some wrong syntax for the `convert` subcommand), same is true (and even worse) for `--help` (but the error message shows then very much information upon an unknown option!)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.