about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-10-06 03:44:47 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-10-06 03:44:47 +0000
commitc018d0cb8f74951c4e6926df3a65e7bf9695a22d (patch)
tree251ce3f8c3898284213cc43e548d3bb74b0a8de9
parent3ec8202a6f3f5b758ba15261aaff11d712eb11fe (diff)
downloadnetpbm-mirror-c018d0cb8f74951c4e6926df3a65e7bf9695a22d.tar.gz
netpbm-mirror-c018d0cb8f74951c4e6926df3a65e7bf9695a22d.tar.xz
netpbm-mirror-c018d0cb8f74951c4e6926df3a65e7bf9695a22d.zip
Check for incompatible options
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3704 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY4
-rwxr-xr-xeditor/pnmquant19
2 files changed, 21 insertions, 2 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 7447303f..f0838cff 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -12,6 +12,10 @@ not yet   BJH  Release 10.89.00
 
                pamfind: Fix typo in message.
 
+               pnmquant: Fail if user specifies both -spreadbrightness and
+               -spreadluminosity or both -randomseed and -norandom, rather
+               than just pick one.
+
 19.09.28  BJH  Release 10.88.00
 
               pnmquant: Fail if user specifies more than one of -meanpixel,
diff --git a/editor/pnmquant b/editor/pnmquant
index 80d8e09f..827d6fde 100755
--- a/editor/pnmquant
+++ b/editor/pnmquant
@@ -199,10 +199,10 @@ sub openSeekableAsStdin($) {
 
 
 
-sub makeColormap($$$$$$) {
+sub makeColormap($$$$$$$) {
 
     my ($ncolors, $opt_center, $opt_meanpixel, $opt_meancolor,
-        $opt_spreadluminosity, $opt_quiet) = @_;
+        $opt_spreadbrightness, $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.
@@ -235,6 +235,16 @@ sub makeColormap($$$$$$) {
         $averageOpt = "-center";
     }
 
+    my $spreadOptCt =
+        (defined($opt_spreadluminosity) ? 1 : 0) +
+        (defined($opt_spreadbrightness) ? 1 : 0);
+
+    if ($spreadOptCt > 1) {
+        print(STDERR "You can specify only one of " .
+              "-spreadluminosity and -spreadbrightness\n");
+        exit(1);
+    }
+
     my $spreadOpt;
     if (defined($opt_spreadluminosity)) {
         $spreadOpt = "-spreadluminosity";
@@ -276,6 +286,10 @@ sub remap($$$$$$) {
         push(@options, "-floyd");
     }
     if ($opt_norandom) {
+        if (defined($opt_randomseed)) {
+             print(STDERR "You cannot specify -randomseed with -norandom\n");
+             exit(1);
+        }
         push(@options, "-norandom");
     }
     if (defined($opt_randomseed)) {
@@ -322,6 +336,7 @@ my $mapfileSpec = makeColormap($cmdlineR->{ncolors},
                                $cmdlineR->{center}, 
                                $cmdlineR->{meanpixel}, 
                                $cmdlineR->{meancolor}, 
+                               $cmdlineR->{spreadbrightness},
                                $cmdlineR->{spreadluminosity},
                                $cmdlineR->{quiet});