Debian Codegraph @

editor/ppmbrighten

raw
1 #! /bin/sh
2
3 # This is just for backward compatibility. New applications should use
4 # 'pambrighten'.
5
6 # We don't try very hard to respond well to invalid syntax, because backward
7 # compatibility is mostly for existing, working applications.
8
9 pambrightenOpts=''
10 normalize='no'
11 expectValue='no'
12
13 for word in "$@"; do
14
15 if test "$expectValue" = 'yes'; then
16 # This is the value of an option, like "40" in "-saturation 40"
17 pambrightenOpts="$pambrightenOpts $word"
18 expectValue='no'
19 else
20 # 'word_one_hyphen' is 'word' except if 'word' is a double-hyphen
21 # option, 'word_one_hyphen' is the single-hyphen version of it.
22 # E.g. word=--saturation word_one_hyphen=-saturation .
23 word_one_hyphen=$(echo "$word" | sed s/^--/-/ )
24
25 case $word_one_hyphen in
26 -version )
27 pambrighten -version; exit $?
28 ;;
29 -normalize|-normaliz|-normali|-normal|-norma|-norm|-nor|-no|-n)
30 normalize='yes'
31 ;;
32 -*=*)
33 pambrightenOpts="$pambrightenOpts $word"
34 # This is an option with value such as "-saturation=40"
35 ;;
36 -*)
37 pambrightenOpts="$pambrightenOpts $word"
38 # Starts with hyphen, no equals sign, so the next word is the
39 # option's value (note that the only valid ppmbrighten flag
40 # option is -normalized, handled above).
41 #
42 # E.g. "-saturation 40"
43 expectValue='yes'
44 ;;
45 *)
46 # Not an option or option value - only non-option argument
47 # ppmbrighten has is optional input file name
48 infile="$word"
49 ;;
50
51 esac
52 fi
53 done
54
55 if test "$normalize" = 'yes'; then
56 pnmnorm -bsingle -wsingle -colorvalue -keephues $infile | \
57 pambrighten $pambrightenOpts | ppmtoppm
58 else
59 pambrighten $pambrightenOpts $infile | ppmtoppm
60 fi