| 1 |
#!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 |
|
| 3 |
# arguments |
| 4 |
if [scip-shell system . . `[`. "$#" -ne 0 ]; then |
| 5 |
echoscip-shell system . . echo. "usage: $0" >&2 |
| 6 |
exit 1 |
| 7 |
fi |
| 8 |
|
| 9 |
# write input into temporary file |
| 10 |
TMP=$(mktempscip-shell system . . mktemp.) |
| 11 |
trap 'rm "$TMP"' EXIT |
| 12 |
catscip-shell system . . cat. > "$TMP" |
| 13 |
|
| 14 |
# determine the mime-type |
| 15 |
if [scip-shell system . . `[`. "$(ddscip-shell system . . dd. if="$TMP" bs=1 count=8 2>/dev/nullscip-shell filesystem . . `/dev/null`. | trscip-shell system . . tr. -d '\0')" = "farbfeld" ]; then |
| 16 |
catscip-shell system . . cat. "$TMP" |
| 17 |
else |
| 18 |
MIME=$(filescip-shell system . . file. -ib "$TMP" | cutscip-shell system . . 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 [scip-shell system . . `[`. ! -x /usr/bin/convertscip-shell filesystem . . `/usr/bin/convert`. ] ; then |
| 29 |
printfscip-shell system . . printf. "%s: cant convert from %s -- missing \`convert' program" "$0" "$MIME" >&2 |
| 30 |
printfscip-shell system . . 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 [scip-shell system . . `[`. $? -ne 0 ]; then |
| 41 |
exit 1 |
| 42 |
else |
| 43 |
exit 0 |
| 44 |
fi |