Taking Pretty Screenshots on Linux

Pretty Linux Screenshot
Because aesthetics matter.

There are many reasons to run Linux, with reliability, performance, and transparency not least among them. On the other hand, the level of visual cohesion maintainable across an ecosystem of loosely federated parts often falls short of the closed-source competition.

Screenshots are a prime example. gnome-screenshot captures images of various combinations of framebuffers, windowing systems, UI toolkits, and application chrome that tend to wind up with awkward cropping and a few pixels leaking through around the edges. Serviceable, but it’s hard not to envy the polish that’s achievable in certain other operating systems.

So what’s there to wait for? Let’s make Linux look good, too.

Polish

Grab a screenshot by invoking gnome-screenshot -wbe none or the appropriate shortcut (alt+prt sc on Ubuntu). Once the image is saved to disk, we’ll follow UNIX fashion and touch it up with a dedicated utility. Here, that’s ImageMagick‘s convert, which can smooth over rough corners and add a bit of a drop shadow for depth.

Here’s the script:

screenshadow() {
  local src="$1"

  # Adjust as needed to suit your desktop environment
  # Defaults set for vanilla Ubuntu.
  local radius=5
  local inset=2

  local height=$(identify -format '%h' "$src")
  local width=$(identify -format '%w' "$src")

  local outfile="pretty_$(basename "$1")"

  convert \
    \( -size ${width}x${height} xc:none -fill white \
      -draw "roundRectangle 0,0 $(($width-$inset)),$(($height-$inset)) $radius,$radius" \
      -draw "rectangle 0,10 $(($width-$inset)),$(($height-$inset))" \
      "$src" -compose SrcIn -composite \) \
    \( -clone 0 -background \#231f20 -shadow 60x15+0+15 \) \
    -reverse -background none -compose Over -layers merge +repage \
    "$outfile"

  echo "Saved to $outfile"
}

Add it to .bash_profile or source it as needed, pass in the screenshot, and watch the magic happen.

$ gnome-screenshot -wbe none -f nethack.png
$ screenshadow nethack.png
Saved to pretty_nethack.png

It’s a bit more trouble than a one-size-fits-all monolith, but it’s opt-in where needed and easily configured to suit the specifics of your own desktop environment.

Featured