about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-09-20 02:07:40 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-09-20 02:07:40 +0000
commitb9058342424ea5f340e512b5dbf3fa3ac4aa17cd (patch)
tree41b17af4842e84b779efb4e703d3665d60c39774
parent0be25e651de4a285c3e5777205d93ca1b9688ba9 (diff)
downloadnetpbm-mirror-b9058342424ea5f340e512b5dbf3fa3ac4aa17cd.tar.gz
netpbm-mirror-b9058342424ea5f340e512b5dbf3fa3ac4aa17cd.tar.xz
netpbm-mirror-b9058342424ea5f340e512b5dbf3fa3ac4aa17cd.zip
Fail if user specifies more than one of -center, -meanpixel, and -meancolor, rather than just pick one
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3680 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY3
-rwxr-xr-xeditor/pnmquant20
2 files changed, 19 insertions, 4 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index cc1df24a..d67b788c 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -6,6 +6,9 @@ CHANGE HISTORY
 
 not yet  BJH  Release 10.88.00
 
+              pnmquant: Fail if user specifies more than one of -meanpixel,
+              -meancolor, and -center, rather than just pick one.
+
               pnmremap: Don't output any part of the image if program fails
               because the maxval of input and map file do not match, in a
               case where matching maxval is required, i.e. the user specified
diff --git a/editor/pnmquant b/editor/pnmquant
index 0bb328d2..80d8e09f 100755
--- a/editor/pnmquant
+++ b/editor/pnmquant
@@ -199,10 +199,10 @@ sub openSeekableAsStdin($) {
 
 
 
-sub makeColormap($$$$$) {
+sub makeColormap($$$$$$) {
 
-    my ($ncolors, $opt_meanpixel, $opt_meancolor, $opt_spreadluminosity,
-        $opt_quiet) = @_;
+    my ($ncolors, $opt_center, $opt_meanpixel, $opt_meancolor,
+        $opt_spreadluminosity, $opt_quiet) = @_;
 
     # Make a colormap of $ncolors colors from the image on Standard Input.
     # Put it in a temporary file and return its name.
@@ -214,8 +214,19 @@ sub makeColormap($$$$$) {
               "errno = $ERRNO\n");
         exit(1);
     }
-
+       
     my $averageOpt;
+
+    my $colorSummaryOptCt =
+        (defined($opt_meanpixel) ? 1 : 0) +
+        (defined($opt_meancolor) ? 1 : 0) +
+        (defined($opt_center)    ? 1 : 0);
+
+    if ($colorSummaryOptCt > 1) {
+        print(STDERR "You can specify only one of " .
+              "-meanpixel, -meancolor, and -center\n");
+        exit(1);
+    }
     if (defined($opt_meanpixel)) {
         $averageOpt = "-meanpixel";
     } elsif (defined($opt_meancolor)) {
@@ -308,6 +319,7 @@ select(OLDOUT);  # avoids Perl bug where it says we never use OLDOUT
 
 
 my $mapfileSpec = makeColormap($cmdlineR->{ncolors}, 
+                               $cmdlineR->{center}, 
                                $cmdlineR->{meanpixel}, 
                                $cmdlineR->{meancolor}, 
                                $cmdlineR->{spreadluminosity},