3 # Make PNG files from regtests
5 # Usage: ./make-regtest-pngs.sh -j CPUs -o/-n
7 # where -j specifies the number of parallel processes to run
8 # (normally CPUs+1). e.g.:
10 # ./make-regtest-pngs.sh -j9
12 # -o means build an old regtest set - the PNGs go in the old-regtest-results
15 # -n means build a new regtest set - the PNGs go in the new-regtest-results
18 # -p uses PDF and the poppler library via pdftocairo for generating bitmaps,
19 # simulating the output for Evince and other previewers using poppler.
20 # pdftocairo may be contained in the poppler-utils package.
22 # -r can be used for specifying a rendering resolution. This
23 # defaults to 101 for poppler and 300 for Ghostscript from PDF.
25 # -g uses Ghostscript for rendering a bitmap version from the PDF,
26 # simulating the output from printing PDF files on a GNU system, so
27 # use a resolution appropriate for print. Antialiasing is not enabled.
29 # -d changes the Ghostscript device used for creating PNG files
30 # (usually png16m, but with -g you might prefer fewer colors for size
31 # reasons, like png16).
33 cpu_count=${CPU_COUNT:-1}
34 backend_opt='--png ${resolution:+=-dresolution=$resolution} ${gsdevice:+=-dpixmap-format=$gsdevice}'
43 while getopts "j:onpr:g" opts; do
48 file_loc="old-regtest-results";;
55 do pdftocairo -png -r ${resolution:-101} -q "$i" &&
61 file_loc="new-regtest-results"
72 gs -sDEVICE=${gsdevice:-png16m} -q -dNOPAUSE \
73 -r${resolution:-300} -dNOPLATFONTS \
74 -dTextAlphaBits=1 -dGraphicsAlphaBits=1 \
75 -sOutputFile="${i%.pdf}-%d.png" "$i" -c quit &&
82 if [ -z "$file_loc" ]; then
83 echo "Must specify old (-o) or new (-n) regtest PNG creation on command line"
87 rm -rf $LILYPOND_BUILD_DIR/out-png-check/$file_loc
88 mkdir -p $LILYPOND_BUILD_DIR/out-png-check/$file_loc
89 cd $LILYPOND_BUILD_DIR/out-png-check/$file_loc
90 ls $LILYPOND_GIT/input/regression/*.ly > dir.txt
91 $LILYPOND_BUILD_DIR/out/bin/lilypond $(eval echo $backend_opt) --relocate \
92 -dinclude-settings=$LILYPOND_GIT/scripts/auxiliar/NoTagline.ly \
93 -djob-count=$cpu_count -dread-file-list "dir.txt"
98 if [ -n "$do_compare" ]; then
101 mkdir -p regtest-diffs
103 for filename in new-regtest-results/*.png; do
104 trimFile=$(basename $filename)
105 if [ -e old-regtest-results/$trimFile ]; then
106 convert new-regtest-results/$trimFile -level 50% NewTest.png
107 convert old-regtest-results/$trimFile -level 50% OldTest.png
108 difference=$(compare -metric AE NewTest.png OldTest.png null: 2>&1 )
112 if [ $difference -gt 1 ];then
113 echo $trimFile": "$difference" differences"
114 compare -dissimilarity-threshold 1 \
115 new-regtest-results/$trimFile \
116 old-regtest-results/$trimFile regtest-diffs/$trimFile
117 convert regtest-diffs/$trimFile -trim regtest-diffs/$trimFile
118 diff_count=$(($diff_count+1))
121 echo "old-regtest-results/"$trimFile" does not exist"
126 echo $diff_count "differences found."