60 lines
1.6 KiB
Plaintext
60 lines
1.6 KiB
Plaintext
$OpenBSD: patch-editor_ppmquantall,v 1.1 2014/01/03 20:16:31 naddy Exp $
|
|
|
|
Convert from bash to sh.
|
|
|
|
--- editor/ppmquantall.orig Tue Apr 28 03:43:45 2009
|
|
+++ editor/ppmquantall Fri Jan 3 19:12:06 2014
|
|
@@ -53,8 +53,6 @@ fi
|
|
|
|
newcolors=$1
|
|
shift
|
|
-nfiles=$#
|
|
-files=($@)
|
|
|
|
# Extract the width and height of each of the images.
|
|
# Here, we make the assumption that the width and height are on the
|
|
@@ -62,14 +60,6 @@ files=($@)
|
|
# To be robust, we need to use Pnmfile to get that information, or
|
|
# Put this program in C and use ppm_readppminit().
|
|
|
|
-widths=()
|
|
-heights=()
|
|
-
|
|
-for i in ${files[@]}; do
|
|
- widths=(${widths[*]} `grep -v '^#' $i | sed '1d; s/ .*//; 2q'`)
|
|
- heights=(${heights[*]} `grep -v '^#' $i | sed '1d; s/.* //; 2q'`)
|
|
-done
|
|
-
|
|
tempdir="${TMPDIR-/tmp}/ppmquantall.$$"
|
|
mkdir $tempdir || { echo "Could not create temporary file. Exiting."; exit 1;}
|
|
chmod 700 $tempdir
|
|
@@ -78,7 +68,7 @@ trap 'rm -rf $tempdir' 0 1 3 15
|
|
|
|
all=$tempdir/pqa.all.$$
|
|
|
|
-pnmcat -topbottom -jleft -white ${files[@]} | pnmquant $newcolors > $all
|
|
+pnmcat -topbottom -jleft -white "$@" | pnmquant $newcolors > $all
|
|
if [ $? != 0 ]; then
|
|
exit $?
|
|
fi
|
|
@@ -86,12 +76,15 @@ fi
|
|
y=0
|
|
i=0
|
|
|
|
-while [ $i -lt $nfiles ]; do
|
|
- pamcut -left 0 -top $y -width ${widths[$i]} -height ${heights[$i]} $all \
|
|
- > ${files[$i]}$ext
|
|
+for f in "$@"; do
|
|
+ width=`grep -v '^#' "$f" | sed '1d; s/ .*//; 2q'`
|
|
+ height=`grep -v '^#' "$f" | sed '1d; s/.* //; 2q'`
|
|
+
|
|
+ pamcut -left 0 -top $y -width $width -height $height $all \
|
|
+ > "$f$ext"
|
|
if [ $? != 0 ]; then
|
|
exit $?
|
|
fi
|
|
- y=$(($y + ${heights[$i]}))
|
|
+ y=$(($y + $height))
|
|
i=$(($i + 1))
|
|
done
|