I would like to take a screenshot from Xvfb display server.

I already tried:

xwd -root -silent -out screen.xwd

but I can't read this file and I couldn't find any software (via Homebrew) which can display or convert it.

Is there any better way of doing that on OS X?

2 Answers 2


netpbm (brew install netpbm) can process xwd files, so you should be able to do the standard Unix X11 process:

$ xwd -root -silent -out screen.xwd
$ xwdtopnm < screen.xwd | pnmtojpeg > screen.jpg
xwdtopnm: writing PPM file
  • I've pnmtojpeg missing, how to install it?
    – kenorb
    Jun 16, 2016 at 8:37
  • It should be part of netpbm; hmm, I don't compile from source - maybe you need to pass additional flags Jun 16, 2016 at 10:49
  • Ok, it seems it is there (brew list netpbm | grep pnmtojpeg).
    – kenorb
    Jun 16, 2016 at 10:51

Ok, it seems using import command from ImageMagick package is much easier, for example:

import -window root screen.jpeg

However when installing imagemagick, it needs to be compiled with X11, e.g.

brew install imagemagick --with-x11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .