]> git.imager.perl.org - imager.git/commitdiff
prevent the parseiptc method from warning when there's no IPTC data to
authorTony Cook <tony@develop=help.com>
Mon, 13 Mar 2006 02:46:48 +0000 (02:46 +0000)
committerTony Cook <tony@develop=help.com>
Mon, 13 Mar 2006 02:46:48 +0000 (02:46 +0000)
process

Imager.pm
t/t101jpeg.t

index 7b1c7a7b9aeb73414f6801835e0b92ff939481dd..50dfe1597b61709720f51554202d4a317f8fd0f2 100644 (file)
--- a/Imager.pm
+++ b/Imager.pm
@@ -3099,7 +3099,8 @@ sub parseiptc {
 
   my $str=$self->{IPTCRAW};
 
-  #print $str;
+  defined $str
+    or return;
 
   @ar=split(/8BIM/,$str);
 
index 2ee310c29b04f9203e79f292209271ed14a25516..a707068fbc3343c805526bbf1e0dea9a9b247381 100644 (file)
@@ -2,7 +2,7 @@
 use strict;
 use lib 't';
 use Imager qw(:all);
-use Test::More tests => 51;
+use Test::More tests => 54;
 
 init_log("testout/t101jpeg.log",1);
 
@@ -30,7 +30,7 @@ if (!i_has_format("jpeg")) {
     $im = Imager->new(xsize=>2, ysize=>2);
     ok(!$im->write(file=>"testout/nojpeg.jpg"), "should fail to write jpeg");
     cmp_ok($im->errstr, '=~', qr/format not supported/, "check no jpeg message");
-    skip("no jpeg support", 47);
+    skip("no jpeg support", 50);
   }
 } else {
   open(FH,">testout/t101.jpg") || die "cannot open testout/t101.jpg for writing\n";
@@ -245,5 +245,20 @@ if (!i_has_format("jpeg")) {
     is($im->tags(name=>'exif_user_comment'), '',
        "check exif_user_comment set correctly");
   }
+
+  { # test parseiptc handling no IPTC data correctly
+    my $saw_warn;
+    local $SIG{__WARN__} = 
+      sub {
+       ++$saw_warn;
+       print "# @_\n";
+      };
+    my $im = Imager->new;
+    ok($im->read(file => 'testout/t101.jpg', type=>'jpeg'),
+       "read jpeg with no IPTC data");
+    ok(!defined $im->{IPTCRAW}, "no iptc data");
+    my %iptc = $im->parseiptc;
+    ok(!$saw_warn, "should be no warnings");
+  }
 }