]> git.imager.perl.org - imager.git/commitdiff
- added --palette action to tools/imager
authorTony Cook <tony@develop=help.com>
Sun, 28 Nov 2004 13:10:36 +0000 (13:10 +0000)
committerTony Cook <tony@develop=help.com>
Sun, 28 Nov 2004 13:10:36 +0000 (13:10 +0000)
Changes
tools/imager

diff --git a/Changes b/Changes
index 1a73579785dca35bc4bec0d30f2a84148ec7443f..3b4689b31bd15423f43a5e44c26a5b85bdf581b8 100644 (file)
--- a/Changes
+++ b/Changes
@@ -911,6 +911,7 @@ Revision history for Perl extension Imager.
 - the BMP reader now validates the bfOffBits value from the BMP header
   and skips to that offset before reading image data.  Previously this
   value was read but otherwise ignored.
 - the BMP reader now validates the bfOffBits value from the BMP header
   and skips to that offset before reading image data.  Previously this
   value was read but otherwise ignored.
+- added --palette action to tools/imager
 
 =================================================================
 
 
 =================================================================
 
index a2bd9fb69582220979b11df5152435dd43f139a5..9aca63f139cd93d1ba88cf2aacc244ae5ed95326 100755 (executable)
@@ -221,6 +221,23 @@ sub req_tags {
   return;
 }
 
   return;
 }
 
+sub req_palette {
+  my ($im, $ignored, $state) = @_;
+
+  print $state->{filename},"\n";
+  if ($im->type eq 'direct') {
+    print "  No palette - this is a direct color image\n";
+  }
+  else {
+    my @colors = $im->getcolors;
+    for my $index (0..$#colors) {
+      printf "%3d: (%3d, %3d, %3d)\n", $index, ($colors[$index]->rgba)[0..2];
+    }
+  }
+
+  return;
+}
+
 sub val_scale {
   my ($option, $value) = @_;
 
 sub val_scale {
   my ($option, $value) = @_;
 
@@ -346,6 +363,7 @@ sub im_functions {
     (
      info => [ \&req_info ],
      tags => [ \&req_tags ],
     (
      info => [ \&req_info ],
      tags => [ \&req_tags ],
+     palette => [ \&req_palette ],
      scale => [ \&req_scale, \&val_scale ],
      rotate => [ \&req_rotate, \&val_rotate ],
      caption => [ \&req_caption ],
      scale => [ \&req_scale, \&val_scale ],
      rotate => [ \&req_rotate, \&val_rotate ],
      caption => [ \&req_caption ],
@@ -477,6 +495,10 @@ file.
 See L<Imager::Files> for file format specific tags and
 L<Imager::ImageTypes> for common tags.
 
 See L<Imager::Files> for file format specific tags and
 L<Imager::ImageTypes> for common tags.
 
+=item --palette
+
+Dumps the palette of the given file, if it is an indexed image.
+
 =item --scale <scalefactor>
 
 =item --scale <width>x<height>
 =item --scale <scalefactor>
 
 =item --scale <width>x<height>