-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimages.sh
executable file
·55 lines (49 loc) · 1.3 KB
/
images.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
SIZE_OPT=""
SUFFIX=""
case ${1} in
*dpi)
DPI="${1%%dpi}"
INKSCAPE_SIZE="--export-dpi ${DPI}"
SUFFIX="_${DPI}dpi.png"
;;
*px)
WIDTH="${1%%px}"
INKSCAPE_SIZE="--export-width ${WIDTH}"
SUFFIX="_${WIDTH}px.png"
esac
mkdir -p images
grep -h ^image:: *.asciidoc | while read IMAGE_LINE ; do
GRAPHNAME="${IMAGE_LINE%%_{*}"
GRAPHNAME="${GRAPHNAME##*/}"
GRAPHPARAMS="${GRAPHNAME##*+}"
GRAPHNAME="${GRAPHNAME%%+*}"
FILE="$(ls graphics/${GRAPHNAME}.* | head -n 1)"
GRAPHTYPE="${FILE##*.}"
[ "${FILE}" -nt "images/${GRAPHNAME}${SUFFIX}" ] &&
{
case ${GRAPHTYPE} in
"dia")
dia -O images -t svg ${FILE}
inkscape --without-gui --export-area-drawing ${INKSCAPE_SIZE} \
--export-png=images/${GRAPHNAME}${SUFFIX} \
images/${GRAPHNAME}.svg
;;
"gp")
gnuplot -e "datafile=\"graphics/data_${GRAPHNAME}.${GRAPHPARAMS}.dat\";" ${FILE} > images/${GRAPHNAME}.${GRAPHPARAMS}.svg
inkscape --without-gui --export-area-drawing ${INKSCAPE_SIZE} \
--export-png=images/${GRAPHNAME}+${GRAPHPARAMS}${SUFFIX} \
images/${GRAPHNAME}.${GRAPHPARAMS}.svg
;;
"png")
cp ${FILE} images/${GRAPHNAME}${SUFFIX}
;;
"svg")
inkscape --without-gui --export-area-drawing ${INKSCAPE_SIZE} \
--export-png=images/${GRAPHNAME}${SUFFIX} \
graphics/${GRAPHNAME}.svg
;;
esac
}
done
exit 0