site  contact  subhomenews

'pngoverlay.sh'

August 14, 2011 — BarryK
The previous blog post announces the latest netpbm, that can overlay PNG images, with transparency:
http://bkhome.org/archive/blog2/201108/netpbm-1155-svn-revision-1543.html

I have written a script, 'pngoverlay.sh', that performs the same as 'pngoverlay':

#!/bin/sh

# Barry Kauler 2011 GPL3 (/usr/share/doc/legal)
#pngoverlay.sh is an alternative to pngoverlay written by vovchik (in BaCon)
# (vovchik's pngoverlay requires X to be running, which may be a disadvantage)
#requires netpbm svn rev 1543 or later, with pamcomp -mixtransparency
#requires three params, 1st and 2nd must exist:
# bottom-image top-image output-image
#overlays the two images, with common areas of transparency in output image.

[ ! $3 ] && exit 1
[ ! -e "$1" ] && exit 1
[ ! -e "$2" ] && exit 1
[ "`echo -n "$1" | grep 'png$'`" = "" ] && exit 1
[ "`echo -n "$2" | grep 'png$'`" = "" ] && exit 1

pngtopam -alphapam "${1}" > /tmp/pngoverlay_${$}_1.pam
pngtopam -alphapam "${2}" > /tmp/pngoverlay_${$}_2.pam
#1st image on top, 2nd on bottom, 3rd is output...
pamcomp -mixtransparency /tmp/pngoverlay_${$}_2.pam /tmp/pngoverlay_${$}_1.pam > /tmp/pngoverlay_${$}_out.png 2> /dev/null
pamrgbatopng /tmp/pngoverlay_${$}_out.png > "${3}"
rm -f /tmp/pngoverlay_${$}_1.pam
rm -f /tmp/pngoverlay_${$}_2.pam
rm -f /tmp/pngoverlay_${$}_out.pam


I have put it into Woof, in /usr/sbin, however have still left in Vovchik's pngoverlay and the latter is still being used. The problem is that it can't be guaranteed that all Woof-built puppies will use this latest netpbm -- some may use an older version supplied by the compatible-distro.

Anyway, I have put the pngoverlay.sh script into Woof with a view to moving over to it one day.

Tags: woof