about summary refs log tree commit diff
path: root/editor
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 /editor
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
Diffstat (limited to 'editor')
-rwxr-xr-xeditor/pnmquant20
1 files changed, 16 insertions, 4 deletions
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},