extend the synopsis a little so people realize type is optional for
authorTony Cook <tony@develop=help.com>
Sat, 29 Nov 2008 23:38:12 +0000 (23:38 +0000)
committerTony Cook <tony@develop=help.com>
Sat, 29 Nov 2008 23:38:12 +0000 (23:38 +0000)
reading and often for writing.

also, simple examples of other data sources/sinks

lib/Imager/Files.pod

index d2b1436e730c86fc3a2772f77ec494203df4e7d3..e3676b15256fdaf9194b2f993f63e3b0b436fbc3 100644 (file)
@@ -8,10 +8,19 @@ Imager::Files - working with image files
   $img->write(file=>$filename, type=>$type)
     or die "Cannot write: ",$img->errstr;
 
+  # type is optional if we can guess the format from the filename
+  $img->write(file => "foo.png")
+    or die "Cannot write: ",$img->errstr;
+
   $img = Imager->new;
   $img->read(file=>$filename, type=>$type)
     or die "Cannot read: ", $img->errstr;
 
+  # type is optional if we can guess the type from the file data
+  # and we normally can guess
+  $img->read(file => $filename)
+    or die "Cannot read: ", $img->errstr;
+
   Imager->write_multi({ file=> $filename, ... }, @images)
     or die "Cannot write: ", Imager->errstr;
 
@@ -23,6 +32,24 @@ Imager::Files - working with image files
   my @read_types = Imager->read_types;
   my @write_types = Imager->write_types;
 
+  # we can write/write_multi to things other than filenames
+  my $data;
+  $img->write(data => \$data, type => $type) or die;
+
+  my $fh = ... ; # eg. IO::File
+  $img->write(fh => $fh, type => $type) or die;
+
+  $img->write(fd => fileno($fh), type => $type) or die;
+
+  # some file types need seek callbacks too
+  $img->write(callback => \&write_callback, type => $type) or die;
+
+  # and similarly for read/read_multi
+  $img->read(data => $data) or die;
+  $img->read(fh => $fh) or die;
+  $img->read(fd => fileno($fh)) or die;
+  $img->read(callback => \&read_callback) or die;
+
 =head1 DESCRIPTION
 
 You can read and write a variety of images formats, assuming you have