#!/bin/sh if [ "$#" -ne 0 ]; then echo "usage: $0" >&2 exit 1 fi TMP=$(mktemp) cat > "$TMP" if [ "$(head -c 8 "$TMP")" = "farbfeld" ]; then cat < "$TMP" exit 0 fi FORMAT=$(file -ib "$TMP" | cut -d ";" -f 1) case "$FORMAT" in image/png) png2ff < "$TMP" ;; image/jpeg) jpg2ff < "$TMP" ;; *) convert "$TMP" png:- 2>/dev/null | png2ff 2>/dev/null ;; esac ret=$? rm "$TMP" if [ $ret -ne 0 ]; then printf "%s: failed to convert from %s\n" "$0" "$FORMAT" >&2 fi exit $ret