Introduction
Introduction Statistics Contact Development Disclaimer Help
revpointer - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
revpointer (1181B)
---
1 #!/bin/sh
2
3 die() {
4 [ -n "$1" ] && printf '%s\n' "$1" >&2
5 exit 1
6 }
7
8 [ $# -ne 2 ] && die "usage: ${0##*/} <file> <outimagefile>"
9
10 mimetype="$(file -ib "$1")"
11 rminfile=0
12 case "$mimetype" in
13 video/*)
14 in="$(mktemp -u tmp.XXXXXXXX.jpg)"
15 ffmpeg -i "$1" -frames:v 1 "$in"
16 if [ $? -gt 0 ];
17 then
18 [ -e "${in}" ] && rm -f "${in}"
19 die
20 fi
21 rminfile=1
22 ;;
23 image/png*)
24 # imagemagick text draw on png files is broken,
25 # tested on gentoo imagemagick version 7.1.0-48
26 in="$(mktemp tmp.XXXXXXXX.jpg)"
27 magick convert "$1" "$in"
28 if [ $? -gt 0 ];
29 then
30 rm "${in}"
31 die
32 fi
33 rminfile=1
34 ;;
35 image/*)
36 in="$1"
37 ;;
38 *)
39 die "file type '${mimetype}' not supported"
40 ;;
41 esac
42
43 n="${1##*/}"
44 n="${n%.*}"
45 tmp="$(mktemp tmp.XXXXXXXXX.jpg)"
46 magick convert \
47 \( \
48 +append \
49 "${in}" \
50 /home/annna/bin/modules/filter-media/revpointer.jpg \
51 -resize x500 \
52 \) \
53 -pointsize 50 -fill white \
54 -stroke black -strokewidth 1 \
55 -gravity southwest \
56 -gravity northeast \
57 -draw "text -422,+440 '&${n}'" \
58 "$tmp"
59 # -draw "text +10,+10 '${n}'" \
60 exitcode=$?
61 if [ $exitcode -eq 0 ];
62 then
63 cp "${tmp}" "$2"
64 chmod o+r "$2"
65 fi
66
67 # cleanup
68 rm "${tmp}"
69 [ $rminfile -eq 1 ] && rm "${in}"
70
71 exit $exitcode
72
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.