#!/bin/sh # Convert existing render-test exports without trimming, resampling or labels # inside the framebuffer. ImageMagick is optional, not a make check dependency. set -eu if [ "$#" -ne 1 ]; then echo "Usage: sh tests/render-images.sh ABSOLUTE_OUTPUT_DIRECTORY" >&2 exit 2 fi cd "$1" for pgm in ./*-[01].pgm; do [ -f "$pgm" ] || continue base=${pgm%.pgm} [ "$(wc -c < "$base.bin")" -eq 860 ] { printf 'P4\n160 43\n'; cat "$base.bin"; } > "$base.pbm" # Compare the packed 1-bit buffer independently with the PGM export. compare -metric AE "$base.pbm" "$pgm" null: 2> "$base-pixels.log" convert "$pgm" +repage -type TrueColor "PNG24:$base-native.png" convert "$base-native.png" -sample 800% +repage "PNG24:$base-8x.png" convert "$base-8x.png" -sample 160x43! +repage "PNG24:$base-roundtrip.png" compare -metric AE "$pgm" "$base-native.png" null: 2>> "$base-pixels.log" compare -metric AE "$pgm" "$base-roundtrip.png" null: 2>> "$base-pixels.log" rm "$base-roundtrip.png" # Smaller contact tiles avoid shrinking wide sheets in image viewers. # Keep the eightfold originals available for individual pixel inspection. convert "$base-native.png" -sample 400% +repage "PNG24:$base-4x.png" done for group in off nvidia amd single dual large unknown odd maximum; do [ -f "$group-0-4x.png" ] || continue montage -font DejaVu-Sans -pointsize 14 -background '#dddddd' \ -label "$group: five-row summary (4x)" "$group-0-4x.png" \ -label "$group: four-row summary (4x)" "$group-1-4x.png" \ -tile 1x2 -geometry +8+8 "PNG24:contact-$group.png" height=$(identify -format '%h' "contact-$group.png") for variant in 0 1; do top=$((8 + variant * height / 2)) convert "contact-$group.png" -crop "640x172+8+$top" +repage \ "PNG24:$group-tile-check.png" compare -metric AE "$group-$variant-4x.png" "$group-tile-check.png" \ null: 2>> "$group-contact-pixels.log" done rm "$group-tile-check.png" done if [ -f contact-off.png ] && [ -f contact-nvidia.png ] && [ -f contact-amd.png ]; then convert contact-off.png contact-nvidia.png contact-amd.png -append +repage \ PNG24:contact-legacy.png fi if [ -f contact-dual.png ] && [ -f contact-large.png ] && [ -f contact-unknown.png ]; then convert contact-dual.png contact-large.png contact-unknown.png -append +repage \ PNG24:contact-metrics.png fi if [ -f contact-odd.png ] && [ -f contact-maximum.png ]; then convert contact-odd.png contact-maximum.png -append +repage PNG24:contact-paging.png fi