Easy Raspberry Pi framebuffer screenshots with raspi2png

I gave a talk about retro-gaming on the Raspberry Pi yesterday. I was describing RetroPie, and I really needed lots of screenshots to illustrate games. I’m used to grabbing screens under X, but RetroPie runs without it, so all my usual tools were of no use.

I’d just found out about raspi2png, and it works really well! Usage is simple: just call it like

raspi2png -p outfile.png

and it’ll save whatever’s on the screen. It doesn’t play well with X, but there are already tools to take screenshots with that. As I was playing games, I didn’t want to have to pause the computer to take a shot, so I ran the command every five seconds for 30*5 seconds like this:

for f in {1..30}; do raspi2png -p retro_$(date -Iseconds).png; sleep 5; done

Here are some quality shots via raspi2png from Deathchase, officially the best ZX Spectrum game ever:

chroma key screen grabs

Oddly-shaped windows are a pain to screen grab. Netpbm to the rescue!

  1. Make a blue (or green, or whatever isn’t used in your window) image larger than the window, like this:
    ppmmake blue 800 600 | pnmtopng > ~/Desktop/b.png
  2. Display the image, and arrange your program in front of it.
  3. Take a screenshot.
  4. Crop the image, and set the background transparent.
    pngtopnm Screen\ shot\ 2011-03-27\ at\ 10.12.52\ .png |\
     pnmcrop |\
     pnmtopng -transparent blue > ICP-2007.png


(and yeah, this is a Windows program running under Wine on OS X …)