#!/bin/sh # usage: ./imgtopng.sh file # Needs file format: # 9 ASCII: "imageRGBA" # 1 Any byte # 9 ASCII string containing width # 1 Any byte # 9 ASCII string containing height # 1 Any byte # w*h Pixels in RGBA, 1 byte per channel sig=`cut -b 1-9 "$1"` if [ "$sig" = "imageRGBA" ]; then w=`cut -b 11-19 "$1"` h=`cut -b 21-29 "$1"` cut -b 31- "$1" | convert -size "$w"x"$h" -depth 8 rgba:- png:- else echo "bad image signature" >/dev/stderr exit 1 fi