pngoverlay.sh 1.0 KB

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. # Barry Kauler 2011 GPL3 (/usr/share/doc/legal)
  3. #pngoverlay.sh is an alternative to pngoverlay written by vovchik (in BaCon)
  4. # (vovchik's pngoverlay requires X to be running, which may be a disadvantage)
  5. #requires netpbm svn rev 1543 or later, with pamcomp -mixtransparency
  6. #requires three params, 1st and 2nd must exist:
  7. # bottom-image top-image output-image
  8. #overlays the two images, with common areas of transparency in output image.
  9. [ ! $3 ] && exit 1
  10. [ ! -e "$1" ] && exit 1
  11. [ ! -e "$2" ] && exit 1
  12. [ "`echo -n "$1" | grep 'png$'`" = "" ] && exit 1
  13. [ "`echo -n "$2" | grep 'png$'`" = "" ] && exit 1
  14. pngtopam -alphapam "${1}" > /tmp/pngoverlay_${$}_1.pam
  15. pngtopam -alphapam "${2}" > /tmp/pngoverlay_${$}_2.pam
  16. #1st image on top, 2nd on bottom, 3rd is output...
  17. pamcomp -mixtransparency /tmp/pngoverlay_${$}_2.pam /tmp/pngoverlay_${$}_1.pam > /tmp/pngoverlay_${$}_out.png 2> /dev/null
  18. pamrgbatopng /tmp/pngoverlay_${$}_out.png > "${3}"
  19. rm -f /tmp/pngoverlay_${$}_1.pam
  20. rm -f /tmp/pngoverlay_${$}_2.pam
  21. rm -f /tmp/pngoverlay_${$}_out.pam