Fix IDs.
[thenextsample.git] / images.sh
blob0dd4871263ef26ce7db8c12535a51f6856db36cb
1 # We do two things:
3 # * Find all the raw files and convert them to PNG files
4 # * List all the PNGs and their meta data in an XML file such
5 # that we can link it up wen generating the main document.
7 rawImages=`find Images/Tiles/ -name "*.nef"`
8 outXMLFile="imageMetaData.xml"
10 # Each raw file follow this pattern:
12 # LNNN_tag_HNN_WNN.nef
14 # where L is either T or W, the "part_" part optional, and the two subsequent numbers the
15 # height and width in millimeters. For instance: T41_H70_W50.nef.
17 echo '<imageMetaData xmlns:d="http://docbook.org/ns/docbook">' > $outXMLFile
19 for raw in $rawImages; do
20 basename=`basename $raw`
21 id=`echo "$basename" | sed -e 's/^\([^_]*\)_.*/\1/'`
22 width=`echo "$basename" | sed -e 's/.*_W\([0-9]*\)\.nef$/\1/'`
23 height=`echo "$basename" | sed -e 's/.*_H\([0-9]*\)\_.*$/\1/'`
24 idTag="$id"
25 path=`dirname $raw`
26 nameOfExport="$id.png"
27 pathOfExport="$path/$nameOfExport"
29 pushd `dirname $raw`
30 convert -rotate -90 $basename $nameOfExport
31 popd
33 echo "<d:mediaobject xml:id=\"TileImage_$idTag\"><d:imageobject>" >> $outXMLFile
34 echo "<d:imagedata fileref=\"../$pathOfExport\" format=\"PNG\" contentdepth=\"$height"mm"\" contentwidth=\"$width"mm"\"/>" >> $outXMLFile
35 echo "</d:imageobject></d:mediaobject>" >> $outXMLFile
36 done
38 echo "</imageMetaData>" >> $outXMLFile