pngstest 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. #
  3. # Usage:
  4. #
  5. # tests/pngstest gamma alpha
  6. #
  7. # Run ./pngstest on the PNG files in $srcdir/contrib/testpngs which have the
  8. # given gamma and opacity:
  9. #
  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"
  17. shift
  18. alpha="$1"
  19. shift
  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";;
  28. *-sRGB[.-]*)
  29. test "$gamma" = "sRGB" && g="$f";;
  30. *-1.8[.-]*)
  31. test "$gamma" = "1.8" && g="$f";;
  32. *)
  33. test "$gamma" = "none" && g="$f";;
  34. esac
  35. case "$g" in
  36. "")
  37. :;;
  38. *-alpha[-.]*)
  39. test "$alpha" = "alpha" && args="$args $g";;
  40. *-tRNS[-.]*)
  41. test "$alpha" = "tRNS" -o "$alpha" = "none" && args="$args $g";;
  42. *)
  43. test "$alpha" = "opaque" -o "$alpha" = "none" && args="$args $g";;
  44. esac
  45. done
  46. # This only works if the arguments don't contain spaces; they don't.
  47. exec ./pngstest --tmpfile "${gamma}-${alpha}-" --log ${1+"$@"} $args