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 # -p uses GNU parallel with the given job count in order to also
13 # parallelize the conversion of PDF files to bitmaps when using -g
14 # or -d. No attempt is made to parallelize the bitmap comparisons
15 # since their memory requirements may be prohibitive.
17 # -o means build an old regtest set - the PNGs go in the old-regtest-results
20 # -n means build a new regtest set - the PNGs go in the new-regtest-results
23 # -c uses PDF and the poppler library via pdftocairo for generating
24 # bitmaps, simulating the output for Evince and other previewers
25 # using poppler. pdftocairo may be contained in the poppler-utils
28 # -r can be used for specifying a rendering resolution. This
29 # defaults to 101 for poppler and 300 for Ghostscript from PDF.
31 # -g uses Ghostscript for rendering a bitmap version from the PDF,
32 # simulating the output from printing PDF files on a GNU system, so
33 # use a resolution appropriate for print. Antialiasing is not enabled.
35 # -d changes the Ghostscript device used for creating PNG files
36 # (usually png16m for direct PNG creation and pngmono for printer simulation)
38 # if any filenames follow, those are the tests to run. In absence
39 # of any filenames, the contents of input/regression are used.
41 cpu_count=${CPU_COUNT:-1}
42 backend_opt='--png ${resolution:+=-dresolution=$resolution} ${gsdevice:+=-dpixmap-format=$gsdevice}'
47 while getopts "j:oncr:gpd:" opts; do
52 file_loc="old-regtest-results";;
58 $1 pdftocairo -png -r ${resolution:-101} -q "$2"
62 file_loc="new-regtest-results"
71 $1 gs -sDEVICE=${gsdevice:-pngmono} -q -dNOPAUSE \
72 -r${resolution:-300} -dNOPLATFONTS \
73 -dTextAlphaBits=1 -dGraphicsAlphaBits=1 \
74 -sOutputFile="${2%.pdf}-%d.png" "$2" -c quit
85 if [ -z "$file_loc" ]; then
86 echo "Must specify old (-o) or new (-n) regtest PNG creation on command line"
90 rm -rf $LILYPOND_BUILD_DIR/out-png-check/$file_loc
91 mkdir -p $LILYPOND_BUILD_DIR/out-png-check/$file_loc
93 cd $LILYPOND_BUILD_DIR/out-png-check/$file_loc
96 ls $LILYPOND_GIT/input/regression/*.ly > dir.txt
102 echo "$i" >> dir.txt;;
104 echo "$OLDPWD/$i" >> dir.txt
109 $LILYPOND_BUILD_DIR/out/bin/lilypond $(eval echo $backend_opt) --relocate \
110 -dinclude-settings=$LILYPOND_GIT/scripts/auxiliar/NoTagline.ly \
111 -djob-count=$cpu_count -dread-file-list "dir.txt"
112 if [ "$backend_opt" = "--pdf" ]
114 if [ $use_parallel = y ]
119 done | parallel -j $cpu_count
124 png_generate "" $i && rm "$i"
131 if [ -n "$do_compare" ]; then
134 mkdir -p regtest-diffs
136 for filename in new-regtest-results/*.png; do
137 trimFile=$(basename $filename)
138 if [ -e "old-regtest-results/$trimFile" ]; then
139 convert new-regtest-results/$trimFile -level 50% NewTest.png
140 convert old-regtest-results/$trimFile -level 50% OldTest.png
141 difference=$(compare -metric AE NewTest.png OldTest.png null: 2>&1 )
145 if [ $difference -gt 1 ];then
146 echo $trimFile": "$difference" differences"
147 compare -dissimilarity-threshold 1 \
148 new-regtest-results/$trimFile \
149 old-regtest-results/$trimFile regtest-diffs/$trimFile
150 convert regtest-diffs/$trimFile -trim regtest-diffs/$trimFile
151 diff_count=$(($diff_count+1))
154 echo "old-regtest-results/"$trimFile" does not exist"
159 echo $diff_count "differences found."