#!/bin/sh # # Set the pixel aspect ratio of one or more PNG files. # bye() { rm -f $tmpppm $tmptxt exit $1 } [ $# -lt 3 ] && { echo "usage: pngasp xunits yunits file ..." >&2; exit 1; } xunits=$1; yunits=$2; shift 2 tmpppm=$(mktemp ~/.pngasp.XXXXXX) || bye 1 tmptxt=$(mktemp ~/.pngasp.XXXXXX) || bye 1 for f in "$@"; do pngtopnm -text $tmptxt "$f" >$tmpppm || bye 1 txtopt=; [ -s $tmptxt ] && txtopt="-ztxt $tmptxt" pnmtopng -gamma 0.4545 -phys $xunits $yunits 0 $txtopt $tmpppm >"$f" || \ bye 1 done bye 0 .