Lets say you have a set of images that you want to add to your website, but you want to make sure that each one has copyright visible and attached to the image. But you want it to be consistent, and not have to pull each one into Gimp or Photoshop in order to add that copyright text. Here's what you do. The Script

These instructions require a knowledge of Bash and Unix.
A bash shell script has been prepared to help you with the addition of copyright text to your image.
Prerequirements:
- Unix: Use of a POSIX compatible Unix is required. Linux, OSX, FreeBSD, etc... are all good. If you are windows user, go install a copy of Cygwin, it's a POSIX compatibility layer on top of windows.
- Bash Shell: If you have Unix, you most likely have Bash already.
- Netpbm: Install a copy of the netpbm tools, using your favorite installer (yum, apt, rpm, deb, tarball, source, etc...)
This pnmcopymark.sh bash shell script.
#!/bin/bash
TEMPDIR=".pnmcopymark"
if [ ! -d "$TEMPDIR" ] ; then
mkdir -p $TEMPDIR
fi
function pnmWidth() {
PNM=$1
pamfile $PNM | \
sed -e "s/^.* \([0-9][0-9]*\) by [0-9][0-9]* .*$/\1/g"
}
function pnmHeight() {
PNM=$1
pamfile $PNM | \
sed -e "s/^.* [0-9][0-9]* by \([0-9][0-9]*\) .*$/\1/g"
}
function pnmAddCopyMark() {
PNM=$1
BGCOLOR="#ffffff"
CMPNM="copymark-text.pnm"
let pnmWidth=`pnmWidth "$PNM"`
let cmWidth=`pnmWidth "$CMPNM"`
let cmHeight=`pnmHeight "$CMPNM"`
ppmmake "$BGCOLOR" $pnmWidth $cmHeight > $TEMPDIR/wide_blank.pnm
if [ $pnmWidth -lt $cmWidth ] ; then
pnmscale -width $pnmWidth "$CMPNM" > $TEMPDIR/scaled_text.pnm
cp $TEMPDIR/scaled_text.pnm $TEMPDIR/text.pnm
else
cp "$CMPNM" $TEMPDIR/text.pnm
fi
pnmpaste -replace $TEMPDIR/text.pnm 0 0 $TEMPDIR/wide_blank.pnm > \
$TEMPDIR/wide_text.pnm
pnmcat -topbottom "$PNM" $TEMPDIR/wide_text.pnm > \
$TEMPDIR/result.pnm
cp $TEMPDIR/result.pnm $PNM
}
PNMT="$TEMPDIR/temp.pnm"
if [ -z "$1" ]; then
pnmtopnm > $PNMT
else
cp $1 $PNMT
fi
pnmAddCopyMark "$PNMT"
pnmtopnm "$PNMT"
rm -rf $TEMPDIR
Executing the Script
Create your copyright text image. In your image editor (Gimp, Photoshop, etc...) create a small sliver of an image that has your copyright text in it. (Only need to do this once!)
copymark-text.png (348x17)
Convert your copymark-text.png image to a PNM file so that netpbm and the script can use it. (Only need to do this once!)
To execute the pnmcopymark.sh script you have to do it the netpbm way, which is to first convert the original image into the PNM format (netpbm internal image format) so it can be piped thru the other tools and scripts before eventually being converted back into the output format you desire.
$ pngtoppm copymark-text.png > copymark-text.pnm
How to take a PNG file and add a copymark to it.
$ pngtopnm flower-red-bold.png | ./pnmcopymark.sh | \
pnmtopng -compression=9 > flower-red-bold-with-copymark.png
How to take a directory full of PNG files and add a copymark to each.
for PNG in *.png
do
echo Adding copymark to $PNG
pngtopnm $PNG | ./pnmcopymark.sh | \
pnmtopng -compression=9 > ${PNG//.png}-with-copymark.png
done
Examples of output
flower-yellow-rock-with-mark.png (433x362)

If your source image is less wide than your copymark-text.pnm image, then the script will scale the copymark-text to fit within the width of the original source image.
flower-red-bold-with-mark.png (325x450)

