]> git.imager.perl.org - imager.git/commitdiff
- set i_format to pnm when reading pnm files and test for it
authorTony Cook <tony@develop=help.com>
Mon, 29 Nov 2004 13:47:20 +0000 (13:47 +0000)
committerTony Cook <tony@develop=help.com>
Mon, 29 Nov 2004 13:47:20 +0000 (13:47 +0000)
Changes
TODO
pnm.c
t/t104ppm.t

diff --git a/Changes b/Changes
index b7d5b4962ebdd3aa3a9f6dab4e43eaa7f77c8608..438ac955a8ffb0b9d120637ce0030480298f8feb 100644 (file)
--- a/Changes
+++ b/Changes
@@ -915,6 +915,7 @@ Revision history for Perl extension Imager.
 - i_img_pal_new() now releases the image object memory if creation
   fails.
 - set i_format to gif when reading gif files and test for it
+- set i_format to pnm when reading pnm files and test for it
 
 =================================================================
 
diff --git a/TODO b/TODO
index a3c7fffd2dcc9f9adba56d322a3aa8c763610fec..565222ecef6a389dbeee8ea7e3ebcf6f9f400426 100644 (file)
--- a/TODO
+++ b/TODO
@@ -8,8 +8,8 @@ PRE-0.44:
   - tga
   - rgb
   - png - done
-  - gif
-  - pnm
+  - gif - done
+  - pnm - done
 - check each file reader for possible integer overflows
   - bmp
   - tiff
diff --git a/pnm.c b/pnm.c
index 9f62522e9c8c15c83c5188c5e0250a474b53618d..148b887ba7df4731f8bdd543a2050fe5234ab64a 100644 (file)
--- a/pnm.c
+++ b/pnm.c
@@ -363,6 +363,8 @@ i_readpnm_wiol(io_glue *ig, int length) {
   
   im = i_img_empty_ch(NULL, width, height, channels);
 
+  i_tags_add(&im->tags, "i_format", 0, "pnm", -1, 0);
+
   switch (type) {
   case 1: /* Ascii types */
   case 2:
index 809e0da2914f424beeb4618c736454c2582bfcc5..1c04414db2018be4a27e3049073bd4a5878e1ebf 100644 (file)
@@ -1,9 +1,9 @@
 #!perl -w
 use Imager ':all';
-require "t/testtools.pl";
+BEGIN { require "t/testtools.pl"; }
 use strict;
 
-print "1..43\n";
+print "1..45\n";
 
 init_log("testout/t104ppm.log",1);
 
@@ -171,6 +171,16 @@ check_gray(13, Imager::i_get_pixel($ooim->{IMG}, 1, 1), 255);
   check_color(43, $green, 127, 127, 0,   "green 4095 pixel");
 }
 
+my $num = 44;
+{ # check i_format is set when reading a pnm file
+  # doesn't really matter which file.
+  my $maxval = Imager->new;
+  okn($num++, $maxval->read(file=>"testimg/maxval.ppm"),
+      "read test file");
+  my ($type) = $maxval->tags(name=>'i_format');
+  isn($num++, $type, 'pnm', "check i_format");
+}
+
 sub openimage {
   my $fname = shift;
   local(*FH);