X-Git-Url: http://git.imager.perl.org/imager.git/blobdiff_plain/790923a46ba1461dc2f955260f1cc9922bb1d8a5..4b0f812ce183aaecec58ab6056592dbb97acdbb3:/t/t102png.t?ds=sidebyside diff --git a/t/t102png.t b/t/t102png.t index d938de9a..a28ae93c 100644 --- a/t/t102png.t +++ b/t/t102png.t @@ -7,7 +7,7 @@ # (It may become useful if the test is moved to ./t subdirectory.) use lib qw(blib/lib blib/arch); -BEGIN { $| = 1; print "1..10\n"; } +BEGIN { $| = 1; print "1..12\n"; } END {print "not ok 1\n" unless $loaded;} use Imager qw(:all); @@ -36,10 +36,14 @@ i_box_filled($timg, 0, 0, 20, 20, $green); i_box_filled($timg, 2, 2, 18, 18, $trans); if (!i_has_format("png")) { - for (2..10) { + for (2..12) { print "ok $_ # skip no png support\n"; } } else { + Imager::i_tags_add($img, "i_xres", 0, "300", 0); + Imager::i_tags_add($img, "i_yres", 0, undef, 200); + # the following confuses the GIMP + #Imager::i_tags_add($img, "i_aspect_only", 0, undef, 1); open(FH,">testout/t102.png") || die "cannot open testout/t102.png for writing\n"; binmode(FH); $IO = Imager::io_new_fd(fileno(FH)); @@ -59,15 +63,22 @@ if (!i_has_format("png")) { print i_img_diff($img, $cmpimg) ? "not ok 4 # saved image different\n" : "ok 4\n"; + my %tags = map { Imager::i_tags_get($img, $_) } + 0..Imager::i_tags_count($img) - 1; + abs($tags{i_xres} - 300) < 1 or print "not "; + print "ok 5 # i_xres: $tags{i_xres}\n"; + abs($tags{i_yres} - 200) < 1 or print "not "; + print "ok 6 # i_yres: $tags{i_yres}\n"; + open FH, "> testout/t102_trans.png" or die "Cannot open testout/t102_trans.png: $!"; binmode FH; $IO = Imager::io_new_fd(fileno(FH)); if (i_writepng_wiol($timg, $IO)) { - print "ok 5\n"; + print "ok 7\n"; } else { - print "ok 5 # skip - png transparency not yet implemented\n"; + print "ok 7 # skip - png transparency not yet implemented\n"; } close FH; @@ -78,10 +89,10 @@ if (!i_has_format("png")) { $cmpimg = i_readpng_wiol($IO, -1) || print "not "; close(FH); - print "ok 6\n"; + print "ok 8\n"; print "# png average mean square pixel difference: ",sqrt(i_img_diff($timg,$cmpimg))/150*150,"\n"; print i_img_diff($timg, $cmpimg) - ? "not ok 7 # saved image different\n" : "ok 7\n"; + ? "not ok 9 # saved image different\n" : "ok 9\n"; # REGRESSION TEST # png.c 1.1 would produce an incorrect image when loading images with @@ -93,7 +104,7 @@ if (!i_has_format("png")) { # 1.1 may segfault here (it does with libefence) my $pimg = i_readpng_wiol($IO,-1) or print "not "; - print "ok 8\n"; + print "ok 10\n"; close FH; open FH, "< testimg/palette_out.png" @@ -102,17 +113,17 @@ if (!i_has_format("png")) { $IO = Imager::io_new_fd(fileno(FH)); my $poimg = i_readpng_wiol($IO, -1) or print "not "; - print "ok 9\n"; + print "ok 11\n"; close FH; if (i_img_diff($pimg, $poimg)) { print <