about summary refs log tree commit diff
path: root/editor/pnmmargin
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
commit1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch)
tree64c8c96cf54d8718847339a403e5e67b922e8c3f /editor/pnmmargin
downloadnetpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pnmmargin')
-rwxr-xr-xeditor/pnmmargin88
1 files changed, 88 insertions, 0 deletions
diff --git a/editor/pnmmargin b/editor/pnmmargin
new file mode 100755
index 00000000..31420f99
--- /dev/null
+++ b/editor/pnmmargin
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# ppmmargin - add a margin to a PNM image
+#
+# Copyright (C) 1991 by Jef Poskanzer.
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose and without fee is hereby granted, provided
+# that the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation.  This software is provided "as is" without express or
+# implied warranty.
+
+tempdir="${TMPDIR-/tmp}/pnmmargin.$$"
+mkdir $tempdir || { echo "Could not create temporary file. Exiting."; exit 1;}
+chmod 700 $tempdir
+
+trap 'rm -rf $tempdir' 0 1 3 15
+
+tmp1=$tempdir/pnmm1
+tmp2=$tempdir/pnmm2
+tmp3=$tempdir/pnmm3
+tmp4=$tempdir/pnmm4
+
+color="-gofigure"
+
+# Parse args.
+while true ; do
+    case "$1" in
+	-w* )
+	color="-white"
+	shift
+	;;
+	-b* )
+	color="-black"
+	shift
+	;;
+	-c* )
+	shift
+	if [ ! ${1-""} ] ; then
+	    echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
+	    exit 1
+	fi
+	color="$1"
+	shift
+	;;
+	-* )
+	echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
+	exit 1
+	;;
+	* )
+	break
+	;;
+    esac
+done
+
+if [ ! ${1-""} ] ; then
+    echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
+    exit 1
+fi
+size="$1"
+shift
+
+if [ ${2-""} ] ; then
+    echo "usage: $0 [-white|-black|-color <colorspec>] <size> [pnmfile]" 1>&2
+    exit 1
+fi
+
+# Capture input file in a tmp file, in case it's a pipe.
+cat $@ > $tmp1
+
+# Construct spacer files.
+case "$color" in
+    -gofigure )
+    pnmcut 0 0 1 1 $tmp1 | pnmtile $size 1 > $tmp2
+    ;;
+    -white | -black )
+    pbmmake $color $size 1 > $tmp2
+    ;;
+    * )
+    ppmmake $color $size 1 > $tmp2
+    ;;
+esac
+pamflip -rotate90 $tmp2 > $tmp3
+
+# Cat things together.
+pnmcat -lr $tmp2 $tmp1 $tmp2 > $tmp4
+pnmcat -tb $tmp3 $tmp4 $tmp3