-
Notifications
You must be signed in to change notification settings - Fork 0
/
images.sh
executable file
·38 lines (31 loc) · 1.32 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
# We do two things:
#
# * Find all the raw files and convert them to PNG files
# * List all the PNGs and their meta data in an XML file such
# that we can link it up wen generating the main document.
rawImages=`find Images/Tiles/ -name "*.dng"`
outXMLFile="imageMetaData.xml"
# Each raw file follow this pattern:
#
# LNNN_tag_HNN_WNN.dng
#
# where L is either T or W, the "tag_" part optional, and the two subsequent numbers the
# height and width in millimeters. For instance: T41_H70_W50.dng.
echo '<imageMetaData xmlns:d="http://docbook.org/ns/docbook">' > $outXMLFile
for raw in $rawImages; do
basename=`basename $raw`
id=`echo "$basename" | sed -e 's/^\([^_]*\)_.*/\1/'`
width=`echo "$basename" | sed -e 's/.*_W\([0-9]*\)\.dng$/\1/'`
height=`echo "$basename" | sed -e 's/.*_H\([0-9]*\)\_.*$/\1/'`
idTag="$id"
path=`dirname $raw`
nameOfExport="$id.png"
pathOfExport="$path/$nameOfExport"
pushd `dirname $raw`
convert -rotate -90 $basename $nameOfExport
popd
echo "<d:mediaobject xml:id=\"TileImage_$idTag\"><d:imageobject>" >> $outXMLFile
echo "<d:imagedata fileref=\"../$pathOfExport\" format=\"PNG\" contentdepth=\"$height"mm"\" contentwidth=\"$width"mm"\"/>" >> $outXMLFile
echo "</d:imageobject></d:mediaobject>" >> $outXMLFile
done
echo "</imageMetaData>" >> $outXMLFile