From ef3920cee18dbc37af6d0f0870d0c78d6c9662c4 Mon Sep 17 00:00:00 2001 From: Ed J Date: Fri, 27 Sep 2024 07:49:30 +0000 Subject: [PATCH] test wpic with JPEG --- IO/Pnm/t/pic_16bit.t | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/IO/Pnm/t/pic_16bit.t b/IO/Pnm/t/pic_16bit.t index 2d137e0c7..ed3ded345 100644 --- a/IO/Pnm/t/pic_16bit.t +++ b/IO/Pnm/t/pic_16bit.t @@ -13,26 +13,30 @@ $PDL::IO::Pic::debug=20; my $tmpdir = tempdir( CLEANUP => 1 ); sub roundtrip { - my ($in, $file, $label, @extra) = @_; + local $Test::Builder::Level = $Test::Builder::Level + 1; + my ($in, $file, $label, $dimonly, @extra) = @_; $file = File::Spec->catfile($tmpdir, $file); $in->wpic($file); my $got = rpic($file, @extra); - ok all($in == $got), "$label image save+restore"; + return is_deeply [$got->dims], [$in->dims] if $dimonly; + eval {ok all($in == $got), "$label image save+restore"}; + is $@, '', "$label compare worked"; } # test save/restore of 8-bit image roundtrip(my $x = sequence(16,16), 'byte_a.pnm', 'pnm byte'); -roundtrip($x, 'byte_a.png', 'png byte', +roundtrip($x, 'byte_a.png', 'png byte', 0, $^O =~ /MSWin32/i ? {FORMAT => 'PNG'} : ()) if $can_png; # test save/restore of 16-bit image -roundtrip( - my $a16 = sequence(256, 255)->ushort * 231, +roundtrip(my $a16 = sequence(256, 255)->ushort * 231, 'tushort_a16.pnm', 'pnm ushort', ); -roundtrip($a16, 'tushort_a16.png', 'png ushort', +roundtrip($a16, 'tushort_a16.png', 'png ushort', 0, $^O =~ /MSWin32/i ? {FORMAT => 'PNG'} : ()) if $can_png; +roundtrip(sequence(byte,3,32,24), 'byte_a.jpg', 'jpeg byte', 1, {FORMAT => 'JPEG'}); + done_testing;