Debian Codegraph @

2ff

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #!/bin/sh
2
3 # arguments
4 if [ "$#" -ne 0 ]; then
5 echo "usage: $0" >&2
6 exit 1
7 fi
8
9 # write input into temporary file
10 TMP=$(mktemp)
11 trap 'rm "$TMP"' EXIT
12 cat > "$TMP"
13
14 # determine the mime-type
15 if [ "$(dd if="$TMP" bs=1 count=8 2>/dev/null | tr -d '\0')" = "farbfeld" ]; then
16 cat "$TMP"
17 else
18 MIME=$(file -ib "$TMP" | cut -d ";" -f 1)
19
20 case "$MIME" in
21 image/png)
22 png2ff < "$TMP"
23 ;;
24 image/jpeg)
25 jpg2ff < "$TMP"
26 ;;
27 *)
•28 if [ ! -x /usr/bin/convert ] ; then
29 printf "%s: cant convert from %s -- missing \`convert' program" "$0" "$MIME" >&2
30 printf "Run \`apt install imagemagick' to install it" >&2
31 exit 1
32 fi
33
34 convert "$TMP" png:- | png2ff
35 ;;
36 esac
37 fi
38
39 # errors
40 if [ $? -ne 0 ]; then
41 exit 1
42 else
43 exit 0
44 fi