Chris Craik | ca2bf81 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Usage: |
| 4 | # |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 5 | # tests/pngstest gamma alpha |
Chris Craik | ca2bf81 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 6 | # |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 7 | # Run ./pngstest on the PNG files in $srcdir/contrib/testpngs which have the |
| 8 | # given gamma and opacity: |
Chris Craik | ca2bf81 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 9 | # |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 10 | # gamma: one of; linear, 1.8, sRGB, none. |
| 11 | # alpha: one of; opaque, tRNS, alpha, none. 'none' is equivalent to !alpha |
| 12 | # |
| 13 | # NOTE: the temporary files pngstest generates have the base name gamma-alpha to |
| 14 | # avoid issues with make -j |
| 15 | # |
| 16 | gamma="$1" |
Chris Craik | ca2bf81 | 2013-07-29 15:28:30 -0700 | [diff] [blame] | 17 | shift |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 18 | alpha="$1" |
| 19 | shift |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 20 | args= |
| 21 | LC_ALL="C" # fix glob sort order to ASCII: |
| 22 | for f in "${srcdir}/contrib/testpngs/"*.png |
| 23 | do |
| 24 | g= |
| 25 | case "$f" in |
| 26 | *-linear[.-]*) |
| 27 | test "$gamma" = "linear" && g="$f";; |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 28 | |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 29 | *-sRGB[.-]*) |
| 30 | test "$gamma" = "sRGB" && g="$f";; |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 31 | |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 32 | *-1.8[.-]*) |
| 33 | test "$gamma" = "1.8" && g="$f";; |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 34 | |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 35 | *) |
| 36 | test "$gamma" = "none" && g="$f";; |
| 37 | esac |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 38 | |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 39 | case "$g" in |
| 40 | "") |
| 41 | :;; |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 42 | |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 43 | *-alpha[-.]*) |
| 44 | test "$alpha" = "alpha" && args="$args $g";; |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 45 | |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 46 | *-tRNS[-.]*) |
| 47 | test "$alpha" = "tRNS" -o "$alpha" = "none" && args="$args $g";; |
Matt Sarett | 9b1fe63 | 2015-11-25 10:21:17 -0500 | [diff] [blame] | 48 | |
Matt Sarett | 1146686 | 2016-02-19 13:41:30 -0500 | [diff] [blame] | 49 | *) |
| 50 | test "$alpha" = "opaque" -o "$alpha" = "none" && args="$args $g";; |
| 51 | esac |
| 52 | done |
| 53 | # This only works if the arguments don't contain spaces; they don't. |
| 54 | exec ./pngstest --tmpfile "${gamma}-${alpha}-" --log ${1+"$@"} $args |