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 cpu_count=${CPU_COUNT:-1}
39 backend_opt='--png ${resolution:+=-dresolution=$resolution} ${gsdevice:+=-dpixmap-format=$gsdevice}'
44 while getopts "j:oncr:gpd:" opts; do
49 file_loc="old-regtest-results";;
55 $1 pdftocairo -png -r ${resolution:-101} -q "$2"
59 file_loc="new-regtest-results"
68 $1 gs -sDEVICE=${gsdevice:-pngmono} -q -dNOPAUSE \
69 -r${resolution:-300} -dNOPLATFONTS \
70 -dTextAlphaBits=1 -dGraphicsAlphaBits=1 \
71 -sOutputFile="${2%.pdf}-%d.png" "$2" -c quit
80 if [ -z "$file_loc" ]; then
81 echo "Must specify old (-o) or new (-n) regtest PNG creation on command line"
85 rm -rf $LILYPOND_BUILD_DIR/out-png-check/$file_loc
86 mkdir -p $LILYPOND_BUILD_DIR/out-png-check/$file_loc
87 cd $LILYPOND_BUILD_DIR/out-png-check/$file_loc
88 ls $LILYPOND_GIT/input/regression/*.ly > dir.txt
89 $LILYPOND_BUILD_DIR/out/bin/lilypond $(eval echo $backend_opt) --relocate \
90 -dinclude-settings=$LILYPOND_GIT/scripts/auxiliar/NoTagline.ly \
91 -djob-count=$cpu_count -dread-file-list "dir.txt"
92 if [ "$backend_opt" = "--pdf" ]
94 if [ $use_parallel = y ]
99 done | parallel -j $cpu_count
104 png_generate "" $i && rm "$i"
111 if [ -n "$do_compare" ]; then
114 mkdir -p regtest-diffs
116 for filename in new-regtest-results/*.png; do
117 trimFile=$(basename $filename)
118 if [ -e old-regtest-results/$trimFile ]; then
119 convert new-regtest-results/$trimFile -level 50% NewTest.png
120 convert old-regtest-results/$trimFile -level 50% OldTest.png
121 difference=$(compare -metric AE NewTest.png OldTest.png null: 2>&1 )
125 if [ $difference -gt 1 ];then
126 echo $trimFile": "$difference" differences"
127 compare -dissimilarity-threshold 1 \
128 new-regtest-results/$trimFile \
129 old-regtest-results/$trimFile regtest-diffs/$trimFile
130 convert regtest-diffs/$trimFile -trim regtest-diffs/$trimFile
131 diff_count=$(($diff_count+1))
134 echo "old-regtest-results/"$trimFile" does not exist"
139 echo $diff_count "differences found."