1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
use strict;
use File::Path ();
use File::Spec::Functions;
use FindBin ();
use Test::More;
use Image::Scale;
eval { require Path::Tiny };
if ( $@ ) {
plan skip_all => 'Path::Tiny not installed';
}
plan tests => 3;
my $tmpdir = catdir( $FindBin::Bin, 'tmp' );
if ( -d $tmpdir ) {
File::Path::rmtree($tmpdir);
}
mkdir $tmpdir;
# Test Path::Tiny stringification
SKIP:
{
skip "Image::Scale not built with libjpeg support", 2 unless Image::Scale->jpeg_version;
my $im = Image::Scale->new( Path::Tiny::path( _f("jpg/rgb.jpg") ) );
is( $im->width, 313, "Path::Tiny stringify in new() ok" );
$im->resize_gd( { width => 50, height => 50 } );
my $outjpg = _tmp("resized.jpg");
$im->save_jpeg( Path::Tiny::path($outjpg) );
ok( -e $outjpg, 'Path::Tiny stringify in save_jpeg() ok' );
}
SKIP:
{
skip "Image::Scale not built with libpng support", 1 unless Image::Scale->png_version;
my $im = Image::Scale->new( _f("png/rgb.png") );
$im->resize_gd( { width => 50, height => 50 } );
my $outpng = _tmp("resized.png");
$im->save_png( Path::Tiny::path($outpng) );
ok( -e $outpng, 'Path::Tiny stringify in save_png() ok' );
}
sub _f {
return catfile( $FindBin::Bin, 'images', shift );
}
sub _tmp {
return catfile( $tmpdir, shift );
}
|