view makeGraphics.sh @ 1026:e4d31e094d24

Changes to get Beginners booke building. The web pages include prev and next links, so to get those right we have to make the tune filenames distinct from the main booke names. So fall back to taking the easy way, and just prefix all tune names with @ or _.
author Jim Hague <jim.hague@acm.org>
date Tue, 18 Feb 2020 15:13:38 +0000
parents b83b49f2a0a0
children 70e1ff83fe34
line wrap: on
line source

#!/bin/bash
#
# Make the tune graphics, EPS, PDF required by web and book into
# graphics/<book>.
#

if [ $# != 1 ]; then
    echo "Usage: makeGraphics.sh <book dir name>"
    exit 1
fi

dir=`pwd`

booke=$dir/$1
graphicsdir=$dir/graphics/$1

mkdir -p $graphicsdir

# Now, for each tune, make the tune graphic.
find $booke -maxdepth 1 -name "*.abc" |
    while read filename
    do
        name=`basename $filename .abc`

        # Already generated?
        if [ -f $graphicsdir/${name}.pdf ]; then
            continue
        fi

        # Make the tune graphic.
        abcm2ps -E -F singletune -O $graphicsdir/$name.eps $filename
        # Make $name.eps so we can build with LaTeX.
        mv $graphicsdir/${name}001.eps $graphicsdir/${name}.eps
        # And make the corresponding PDF.
        epstopdf --outfile=$graphicsdir/$name-tocrop.pdf $graphicsdir/${name}.eps
        # And crop it, so the graphic is as big as possible on the page.
        pdfcrop $graphicsdir/$name-tocrop.pdf $graphicsdir/$name.pdf
        rm $graphicsdir/$name-tocrop.pdf

        # and make the first line graphic.
        $dir/abcfirstline.py $filename > firstline.abc
        abcm2ps -E -F firstline -O $graphicsdir/firstline-$name.eps firstline.abc
        mv $graphicsdir/firstline-${name}001.eps $graphicsdir/firstline-${name}.eps
        rm firstline.abc
        epstopdf --outfile=$graphicsdir/firstline-$name-tocrop.pdf $graphicsdir/firstline-${name}.eps
        # And crop it, so the graphic is as big as possible on the page.
        pdfcrop $graphicsdir/firstline-$name-tocrop.pdf $graphicsdir/firstline-$name.pdf
        rm $graphicsdir/firstline-$name-tocrop.pdf
    done

# And make any compact tune graphics.
if [ ! -d ${booke}/Compact ]; then
    exit
fi

find ${booke}/Compact -maxdepth 1 -name "*.abc" |
    while read filename
    do
        name=`basename $filename .abc`

        # Already generated?
        if [ -f $graphicsdir/compact-${name}.pdf ]; then
            continue
        fi

        # Make the tune graphic.
        abcm2ps -E -F singletune -O $graphicsdir/compact-${name}.eps $filename
        # Make $name.eps so we can build with LaTeX.
        mv $graphicsdir/compact-${name}001.eps $graphicsdir/compact-${name}.eps
        # And make the corresponding PDF.
        epstopdf --outfile=$graphicsdir/compact-${name}-tocrop.pdf $graphicsdir/compact-${name}.eps
        # And crop it, so the graphic is as big as possible on the page.
        pdfcrop $graphicsdir/compact-${name}-tocrop.pdf $graphicsdir/compact-${name}.pdf
        rm $graphicsdir/compact-${name}-tocrop.pdf
    done