From b9058342424ea5f340e512b5dbf3fa3ac4aa17cd Mon Sep 17 00:00:00 2001 From: giraffedata Date: Fri, 20 Sep 2019 02:07:40 +0000 Subject: 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 --- editor/pnmquant | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'editor') 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}, -- cgit 1.4.1