From: Tony Cook Date: Mon, 28 Jun 2010 09:43:20 +0000 (+0000) Subject: RT 58761: fix Imager->new(data => $data) X-Git-Tag: Imager-0.77~27 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/7581284100ae1c2ccbb921764d53e2af721f3ded RT 58761: fix Imager->new(data => $data) --- diff --git a/Changes b/Changes index da01f680..32f1569e 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,15 @@ Imager release history. Older releases can be found in Changes.old -Imager 0.75 +Imager 0.76 +=========== + +Bugs: + + - Imager->new(data => $data) didn't try to process image file data in + $data + https://rt.cpan.org/Ticket/Display.html?id=58761 + +Imager 0.75 - 20 Jun 2010 =========== - use PERL_NO_GET_CONTEXT to slightly improve performance on threaded diff --git a/Imager.pm b/Imager.pm index 458d6949..1cc70d72 100644 --- a/Imager.pm +++ b/Imager.pm @@ -644,7 +644,8 @@ sub new { defined $hsh{fh} || defined $hsh{fd} || defined $hsh{callback} || - defined $hsh{readcb}) { + defined $hsh{readcb} || + defined $hsh{data}) { # allow $img = Imager->new(file => $filename) my %extras; diff --git a/t/t104ppm.t b/t/t104ppm.t index dc7ddb28..a72dc22a 100644 --- a/t/t104ppm.t +++ b/t/t104ppm.t @@ -1,6 +1,6 @@ #!perl -w use Imager ':all'; -use Test::More tests => 177; +use Test::More tests => 181; use strict; use Imager::Test qw(test_image_raw test_image_16 is_color3 is_color1 is_image); @@ -552,6 +552,19 @@ print "# check error handling\n"; ok(!$im2, "no image when file failed to load"); cmp_ok(Imager->errstr, '=~', "bad header magic, not a PNM file", "check error message transferred"); + + # load from data + SKIP: + { + ok(open(FH, "< testimg/penguin-base.ppm"), "open test file") + or skip("couldn't open data source", 4); + my $imdata = do { local $/; }; + close FH; + ok(length $imdata, "we got the data"); + my $im3 = Imager->new(data => $imdata); + ok($im3, "read the file data"); + is($im3->getwidth, 164, "check width matches image"); + } } sub openimage {