Description: with the test files excluded, the tests need to be adapted Author: Paul Gevers Forwarded: not needed --- a/t/jpeg.t +++ b/t/jpeg.t @@ -11,7 +11,7 @@ use Image::Scale; my $jpeg_version = Image::Scale->jpeg_version(); if ($jpeg_version) { - plan tests => 117; + plan tests => 112; } else { plan skip_all => 'Image::Scale not built with libjpeg support'; @@ -343,49 +343,6 @@ SKIP: is( _compare( _load($outfile), "rgb_resize_gd_fixed_point_w100.jpg" ), 1, "JPEG resize_gd_fixed_point multiple from scalar ok" ); } -# resize corrupted JPEG in scalar. This caused an infinite loop bug in < 0.14 -# Note: corrupt.jpeg and truncated.jpg didn't trigger this bug -{ - my $dataref = _load( _f("corrupt-sv-infinite-loop.jpg") ); - - my $im = Image::Scale->new($dataref); - $im->resize_gd_fixed_point( { width => 100 } ); - my $out = $im->as_jpeg; - - # We want to always test this, so just check that we got a JPEG back - is( unpack( 'H*', substr( $out, 0, 4 ) ), 'ffd8ffe0', 'corrupt-sv-infinite-loop.jpg resize in-memory ok'); -} - -# offset image in MP3 ID3v2 tag -SKIP: -{ - my $outfile = _tmp("apic_gd_fixed_point_w50.jpg"); - my $im = Image::Scale->new( - _f('v2.4-apic-jpg-351-2103.mp3'), - { offset => 351, length => 2103 } - ); - - is( $im->width, 192, 'JPEG from offset ID3 tag width ok' ); - is( $im->height, 256, 'JPEG from offset ID3 tag height ok' ); - - $im->resize_gd_fixed_point( { width => 50 } ); - $im->save_jpeg($outfile); - - skip "libjpeg version is $jpeg_version, skipping file comparison tests (they require v62)", 1 - if $jpeg_version != 62; - - # These break when using libjpeg-turbo v62, just skip them instead of adding turbo detection - skip "Skipping binary comparison tests (TEST_COMPARE=1 to test)", 1 unless $ENV{TEST_COMPARE}; - - is( _compare( _load($outfile), "apic_gd_fixed_point_w50.jpg" ), 1, "JPEG resize_gd_fixed_point from offset ID3 tag ok" ); -} - -# Exif tag larger than 4K -{ - my $im = Image::Scale->new( _f('large-exif.jpg') ); - is( $im->width, 200, 'JPEG large Exif ok' ); -} - # XXX fatal errors during compression, will this ever actually happen? # XXX progressive JPEG with/without memory_limit Index: b/t/png.t =================================================================== --- a/t/png.t +++ b/t/png.t @@ -13,7 +13,7 @@ use Image::Scale; my $png_version = Image::Scale->png_version(); if ($png_version) { - plan tests => 46; + plan tests => 4; } else { plan skip_all => 'Image::Scale not built with libpng support'; @@ -25,46 +25,6 @@ if ( -d $tmpdir ) { } mkdir $tmpdir; -my @types = qw( - rgb - rgba - rgba_interlaced - rgba16 - gray - gray_alpha - gray_interlaced - palette - palette_alpha -); - -# We don't need to test all resizes, JPEG can do that -my @resizes = qw( - resize_gd_fixed_point -); - -# width/height -for my $type ( @types ) { - my $im = Image::Scale->new( _f("${type}.png") ); - - is( $im->width, 160, "PNG $type width ok" ); - is( $im->height, 120, "PNG $type height ok" ); -} - -# Normal width resize -for my $resize ( @resizes ) { - for my $type ( @types ) { - my $outfile = _tmp("${type}_${resize}_w100.png"); - - my $im = Image::Scale->new( _f("${type}.png") ); - $im->$resize( { width => 100 } ); - $im->save_png($outfile); - my $data = $im->as_png(); - - is( _compare( _load($outfile), "${type}_${resize}_w100.png" ), 1, "PNG $type $resize 100 file ok" ); - is( _compare( \$data, "${type}_${resize}_w100.png" ), 1, "PNG $type $resize 100 scalar ok" ); - } -} - # XXX palette_bkgd # corrupt files from PNG test suite @@ -95,61 +55,6 @@ for my $resize ( @resizes ) { # XXX test for valid header but error during image_png_load() -# multiple resize calls on same $im object, should throw away previous resize data -{ - for my $resize ( @resizes ) { - my $outfile = _tmp("rgba_multiple_${resize}.png"); - my $im = Image::Scale->new( _f("rgba.png") ); - $im->$resize( { width => 50 } ); - $im->$resize( { width => 75 } ); - $im->save_png($outfile); - - is( _compare( _load($outfile), "rgba_multiple_${resize}.png" ), 1, "PNG multiple resize $resize ok" ); - } -} - -# resize from PNG in scalar -{ - my $dataref = _load( _f("rgba.png") ); - - my $outfile = _tmp("rgba_resize_gd_fixed_point_w100.png"); - my $im = Image::Scale->new($dataref); - $im->resize_gd_fixed_point( { width => 100 } ); - $im->save_png($outfile); - - is( _compare( _load($outfile), "rgba_resize_gd_fixed_point_w100.png" ), 1, "PNG resize_gd_fixed_point from scalar ok" ); -} - -# resize multiple from PNG scalar -{ - my $dataref = _load( _f("rgba.png") ); - - my $outfile = _tmp("rgba_resize_gd_fixed_point_w100.png"); - my $im = Image::Scale->new($dataref); - $im->resize_gd_fixed_point( { width => 150 } ); - $im->resize_gd_fixed_point( { width => 100 } ); - $im->save_png($outfile); - - is( _compare( _load($outfile), "rgba_resize_gd_fixed_point_w100.png" ), 1, "PNG resize_gd_fixed_point multiple from scalar ok" ); -} - -# offset image in MP3 ID3v2 tag -{ - my $outfile = _tmp("apic_gd_fixed_point_w50.png"); - my $im = Image::Scale->new( - _f('v2.4-apic-png-350-58618.mp3'), - { offset => 350, length => 58618 } - ); - - is( $im->width, 320, 'PNG from offset ID3 tag width ok' ); - is( $im->height, 240, 'PNG from offset ID3 tag height ok' ); - - $im->resize_gd_fixed_point( { width => 50 } ); - $im->save_png($outfile); - - is( _compare( _load($outfile), "apic_gd_fixed_point_w50.png" ), 1, "PNG resize_gd_fixed_point from offset ID3 tag ok" ); -} - # 1-height image that would previously try to resize to 0-height { my $dataref = _load( _f("height1.png") ); Index: b/t/gif.t =================================================================== --- a/t/gif.t +++ b/t/gif.t @@ -12,7 +12,7 @@ my $gif_version = Image::Scale->gif_vers my $png_version = Image::Scale->png_version(); if ($gif_version) { - plan tests => 18; + plan tests => 3; } else { plan skip_all => 'Image::Scale not built with giflib support'; @@ -24,42 +24,6 @@ if ( -d $tmpdir ) { } mkdir $tmpdir; -my @types = qw( - transparent - white - interlaced_256 -); - -my @resizes = qw( - resize_gd_fixed_point -); - -# width/height -for my $type ( @types ) { - my $im = Image::Scale->new( _f("${type}.gif") ); - - is( $im->width, 160, "GIF $type width ok" ); - is( $im->height, 120, "GIF $type height ok" ); -} - -# Normal width resize -SKIP: -{ - skip "PNG support not built, skipping file comparison tests", 3 if !$png_version; - - for my $resize ( @resizes ) { - for my $type ( @types ) { - my $outfile = _tmp("${type}_${resize}_w100.png"); - - my $im = Image::Scale->new( _f("${type}.gif") ); - $im->$resize( { width => 100 } ); - $im->save_png($outfile); - - is( _compare( _load($outfile), "${type}_${resize}_w100.png" ), 1, "GIF $type $resize 100 file ok" ); - } - } -} - # corrupt file { no strict 'subs'; @@ -84,71 +48,6 @@ SKIP: like( (Test::NoWarnings::warnings())[0]->getMessage, qr/Image::Scale unable to read GIF file/i, 'GIF corrupt error output ok' ); } -# multiple resize calls on same $im object, should throw away previous resize data -SKIP: -{ - skip "PNG support not built, skipping file comparison tests", 1 if !$png_version; - - my $outfile = _tmp("transparent_multiple_resize_gd_fixed_point.png"); - my $im = Image::Scale->new( _f("transparent.gif") ); - $im->resize_gd_fixed_point( { width => 50 } ); - $im->resize_gd_fixed_point( { width => 100 } ); - $im->save_png($outfile); - - is( _compare( _load($outfile), "transparent_multiple_resize_gd_fixed_point.png" ), 1, "GIF multiple resize_gd_fixed_point ok" ); -} - -# resize from GIF in scalar -SKIP: -{ - skip "PNG support not built, skipping file comparison tests", 1 if !$png_version; - - my $dataref = _load( _f("transparent.gif") ); - - my $outfile = _tmp("transparent_resize_gd_fixed_point_w100_scalar.png"); - my $im = Image::Scale->new($dataref); - $im->resize_gd_fixed_point( { width => 100 } ); - $im->save_png($outfile); - - is( _compare( _load($outfile), "transparent_resize_gd_fixed_point_w100.png" ), 1, "GIF resize_gd_fixed_point from scalar ok" ); -} - -# resize multiple from GIF scalar -SKIP: -{ - skip "PNG support not built, skipping file comparison tests", 1 if !$png_version; - - my $dataref = _load( _f("transparent.gif") ); - - my $outfile = _tmp("transparent_multiple_resize_gd_fixed_point_w100_scalar.png"); - my $im = Image::Scale->new($dataref); - $im->resize_gd_fixed_point( { width => 150 } ); - $im->resize_gd_fixed_point( { width => 100 } ); - $im->save_png($outfile); - - is( _compare( _load($outfile), "transparent_resize_gd_fixed_point_w100.png" ), 1, "GIF resize_gd_fixed_point multiple from scalar ok" ); -} - -# offset image in MP3 ID3v2 tag -SKIP: -{ - my $outfile = _tmp("apic_gd_fixed_point_w100.png"); - my $im = Image::Scale->new( - _f('v2.4-apic-gif-318-5169.mp3'), - { offset => 318, length => 5169 } - ); - - is( $im->width, 160, 'GIF from offset ID3 tag width ok' ); - is( $im->height, 120, 'GIF from offset ID3 tag height ok' ); - - $im->resize_gd_fixed_point( { width => 100 } ); - - skip "PNG support not built, skipping file comparison tests", 1 if !$png_version; - - $im->save_png($outfile); - - is( _compare( _load($outfile), "apic_gd_fixed_point_w100.png" ), 1, "GIF resize_gd_fixed_point from offset ID3 tag ok" ); -} # Bug 17573, very thin gif could cause divide by 0 errors SKIP: