summaryrefslogtreecommitdiff
path: root/2ff
blob: 6d89499def5c331a2db99fff80edae49738a1eb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
if [ "$#" -ne 0 ]; then
	echo "usage: $0" >&2
	exit 1
fi

TMP=$(mktemp)
cat > $TMP;

FORMAT=$(file -ib $TMP | cut -d ";" -f 1);

case "$FORMAT" in
    image/png)  png2ff < $TMP; ret=$? ;;
    image/jpeg) jpg2ff < $TMP; ret=$? ;;
    *) xconvert $TMP png:- 2>/dev/null | png2ff 2>/dev/null; ret=$? ;;
esac

rm $TMP;

if [ $ret -ne 0 ]; then
	printf "%s: failed to convert %s\n" "$0" "$FORMAT" >&2;
fi

exit $ret;