Skip to content

Commit

Permalink
test wpic with JPEG
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Sep 27, 2024
1 parent 99edaec commit ef3920c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions IO/Pnm/t/pic_16bit.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit ef3920c

Please sign in to comment.