#!/bin/sh # View an image with ImageMagick. view() { # Extract header hdr=`head -c 30` # Separate fields sig=`echo "$hdr" | cut -b 1-9` w=`echo "$hdr" | cut -b 11-19` h=`echo "$hdr" | cut -b 21-29` # Check signature if [ "x$sig" = "ximageRGBA" ]; then display -size "$w"x"$h" -depth 8 rgba:- else echo "bad image signature" >/dev/stderr exit 1 fi } if [ "x$1" = "x" ]; then view else view < "$1" fi