tshirt-design - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- tshirt-design (1202B) --- 1 #!/bin/sh 2 3 mediadir=/home/annna/bin/modules/filter-media 4 5 die() { 6 printf '%s\n' "$1" >&2 7 exit 1 8 } 9 10 if test $# -ne 2; then 11 die "usage: ${0##*/} <file> <outimagefile>" 12 fi 13 14 mimetype="$(file -ib "$1")" 15 case "$mimetype" in 16 video/*) 17 in="$(mktemp).jpg" 18 ffmpeg -i "$1" -frames:v 1 "$in";; 19 image/*) 20 in="$1";; 21 *) 22 die "file type '${mimetype}' not supported";; 23 esac 24 25 shirt="$(shuf -n 1 -e "${mediadir}"/tshirt*.jpg)" 26 27 case "$shirt" in 28 */tshirt1.jpg) 29 size=400x600 30 geometry=+0+50 31 rotate=-3 ;; 32 */tshirt2.jpg) 33 size=350x400 34 geometry=-10-75 35 rotate=0 ;; 36 */tshirt3.jpg) 37 size=180x350 38 geometry=+0+50 39 rotate=-2 ;; 40 */tshirt4.jpg) 41 size=200x450 42 geometry=-10+50 43 rotate=0 ;; 44 */tshirt5.jpg) 45 size=200x450 46 geometry=+5+100 47 rotate=0 ;; 48 */tshirt6.jpg) 49 size=300x450 50 geometry=+5-50 51 rotate=0 ;; 52 */tshirt7.jpg) 53 size=400x550 54 geometry=+5+0 55 rotate=0 ;; 56 */tshirt8.jpg) 57 size=300x500 58 geometry=-15+80 59 rotate=-2 ;; 60 *) 61 die "unknown tshirt: $tshirt";; 62 esac 63 64 magick convert "$shirt" \ 65 \( "${in}" \ 66 -matte \ 67 -virtual-pixel transparent \ 68 -background transparent \ 69 -resize "$size" \ 70 -rotate "$rotate" \ 71 \) \ 72 -geometry "$geometry" \ 73 -gravity center \ 74 -composite "$2"