]> git.imager.perl.org - imager.git/commitdiff
- added tools/imager to the distribution. This is still very
authorTony Cook <tony@develop=help.com>
Thu, 25 Nov 2004 12:59:26 +0000 (12:59 +0000)
committerTony Cook <tony@develop=help.com>
Thu, 25 Nov 2004 12:59:26 +0000 (12:59 +0000)
  experimental and untested.  Patches welcome, if you write tests to go
  with them.

Changes
MANIFEST
tools/imager

diff --git a/Changes b/Changes
index 9e2059d371034fb8462e5139ef144a8a326d6328..a8096e37f83aae2d8dce801ad1c75b4d0ee9a753 100644 (file)
--- a/Changes
+++ b/Changes
@@ -877,6 +877,7 @@ Revision history for Perl extension Imager.
   resolve https://rt.cpan.org/Ticket/Display.html?id=7948
 - i_writegif_low() wasn't setting the returned global palette, which
   meant a rubbish palette was returned to the user (detected with valgrind)
+- built 0.43_02 for testing
 
 0.43_03
 
@@ -904,6 +905,9 @@ Revision history for Perl extension Imager.
     but one step at a time)
 - added bmp_compression_name, bmp_used_colors, bmp_filesize, bmp_bit_count 
   tags on reading a BMP file
+- added tools/imager to the distribution.  This is still very 
+  experimental and untested.  Patches welcome, if you write tests to go
+  with them.
 
 =================================================================
 
index 43653ca7e640f8ac92d072d6b8e402c5bad96240..e1a0d04c19cb4e5ad6df115dbfee895ad0a94dc1 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -205,6 +205,7 @@ testimg/trimgdesc.gif
 testimg/trmiddesc.gif
 tga.c           Reading and writing Targa files
 tiff.c
+tools/imager    Command-line tool for imager (experimental)
 trans2.c
 transform.perl Shell interface to Imager::Transform
 typemap
index 064010eaa7934721d4913cbceb4d907e3effe646..a2bd9fb69582220979b11df5152435dd43f139a5 100755 (executable)
@@ -12,8 +12,10 @@ my $help;
 my $verbose;
 my $backup; # backup extension name
 my $directory; # output directory
+my $output;
 my $type;
 my %write_opts; # options supplied to write()
+my $understand;
 
 my @collection; # actions/options in order to allow us to set values as needed
 
@@ -67,15 +69,30 @@ GetOptions('help' => sub { $help_func->("synopsis") },
           'type|t=s' => \$type, # output file type
           'write-option|wo=s' => \%write_opts,
           'output|o=s' => \$output,
+           'understand' => \$understand,
 
           @getoptions,
 
           'help-color-spec' => sub { $help_func->("color specifications") },
+           'help-actions' => sub { $help_func->("actions") },
+           'help-options' => sub { $help_func->("processing options") },
+           'help-general' => sub { $help_func->("general options") },
          )
   or usage();
 
 $did_help and exit;
 
+unless ($understand) {
+  print STDERR <<EOS;
+This tool is under-tested and will probably destroy your data.
+
+If you understand and agree with this use the --understand option.
+
+In fact, only the --info and --tags actions have been used at all.
+EOS
+  die;
+}
+
 exists $write_opts{file}
   and die "Illegal write option 'file'\n";
 exists $write_opts{type}
@@ -138,6 +155,9 @@ for my $name (@ARGV) {
       }
     }
   }
+  else {
+    print STDERR "Failed reading $name: ",$im->errstr,"\n";
+  }
 }
 
 sub _replace_codes {
@@ -188,6 +208,19 @@ sub req_info_format {
   $im;
 }
 
+sub req_tags {
+  my ($im, $ignored, $state) = @_;
+
+  print $state->{filename},"\n";
+  my @tags = $im->tags;
+  for my $tag (sort { $a->[0] cmp $b->[0] } @tags) {
+    my $name = shift @$tag;
+    print "  $name: @$tag\n";
+  }
+
+  return;
+}
+
 sub val_scale {
   my ($option, $value) = @_;
 
@@ -312,6 +345,7 @@ sub im_functions {
   return
     (
      info => [ \&req_info ],
+     tags => [ \&req_tags ],
      scale => [ \&req_scale, \&val_scale ],
      rotate => [ \&req_rotate, \&val_rotate ],
      caption => [ \&req_caption ],
@@ -411,9 +445,12 @@ imager - Imager command-line image manipulation tool
  imager  [--font-size <size>] [--fs <size>] [--background <color>] 
     [--bg <color>] [--foreground <color>] [--fg <color] 
     [--info-format <format>] [--rotate <angle>] [--scale <scale-spec>] 
-    [--caption <text>] [--info] [--font fontfile] files ...
+    [--caption <text>] [--info] [--tags] [--font fontfile] files ...
  imager --help-I<option>
- imager  --help-I<operation>
+ imager --help-I<operation>
+ imager --help-options
+ imager --help-actions
+ imager --help-general
 
 =head1 DESCRIPTION
 
@@ -432,6 +469,14 @@ source image type.
 
 No output image file is produced.
 
+=item --tags
+
+Displays all the tags the Imager reader for that format sets for each
+file.
+
+See L<Imager::Files> for file format specific tags and
+L<Imager::ImageTypes> for common tags.
+
 =item --scale <scalefactor>
 
 =item --scale <width>x<height>