-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtxt2gif
40 lines (34 loc) · 1.18 KB
/
txt2gif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
#
# txt2gif [-fmt] file
#
# Convert a plain text file into a GIF image for magick display on the IM Example
# pages. The GIF image filename is exactly the same as the given input
# filename but with a ".gif" suffix appended.
#
###
#
# Anthony Thyssen <A.Thyssen@grffith.edu.au>
if [ "X$1" = "X-fmt" ]; then
shift
fmt="fmt -s"
else
fmt="cat"
fi
# IM Example settings common to all examples
[ -f ./generate_options ] && . ./generate_options
[ -f ../generate_options ] && . ../generate_options
[ -f ../../generate_options ] && . ../../generate_options
# TXT2GIF conversion
FONT="-font CourierNew -pointsize 12"
#FONT="-font CourierNew -pointsize 8"
#FONT="-font LucidaSansTypewriter -pointsize 10"
#FONT="-font Crystal -pointsize 12"
#FONT="-font LiberationMono -pointsize 12"
[ "X$txt_bg_color" = "X" ] && txt_bg_color='#cccccc'
expand "$1" | $fmt | # Expand tabs (and posibly reformat text)
perl -0777 -pe 's/\n$//' | # Remove last newline from txt input
#sed 's/\\/\\\\/g' | # Escape escapes -- removed IM v6.3.3
magick $FONT -background "$txt_bg_color" label:@- \
-bordercolor "$txt_bg_color" -border 1 \
"$1.gif"