From 642a675b46bf0893d08a82d838efd81470635cd4 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Mon, 29 Nov 2004 13:47:20 +0000 Subject: [PATCH] - set i_format to pnm when reading pnm files and test for it --- Changes | 1 + TODO | 4 ++-- pnm.c | 2 ++ t/t104ppm.t | 14 ++++++++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index b7d5b496..438ac955 100644 --- 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 a3c7fffd..565222ec 100644 --- 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 9f62522e..148b887b 100644 --- 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: diff --git a/t/t104ppm.t b/t/t104ppm.t index 809e0da2..1c04414d 100644 --- a/t/t104ppm.t +++ b/t/t104ppm.t @@ -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); -- 2.39.5