Image-Epeg

 view release on metacpan or  search on metacpan

benchmark/simple.pl  view on Meta::CPAN

use strict;
use warnings;
use Image::Epeg qw(:constants);
use Benchmark ':all';
use GD;
use Imager;
use Image::Magick;

print "# Image::Epeg   $Image::Epeg::VERSION\n";
print "# Imager        $Imager::VERSION\n";
print "# GD            $GD::VERSION\n";
print "# Image::Magick $Image::Magick::VERSION\n";

my $srcfile = shift or die "Usage: $0 fname";
my $src = Image::Epeg->new($srcfile);
print "# origsize: @{[ $src->get_width ]} x @{[ $src->height ]}\n";
my $width = int($src->get_width * 0.4);
my $height = int($src->get_height * 0.4);
print "# size: $width x $height\n";

timethese(
    1 => {

benchmark/simple.pl  view on Meta::CPAN

                        $gd->width, $gd->height );

                    open my $fh, '>', "gd-$method.jpg";
                    print $fh $scaled->jpeg;
                    close $fh;
                };
            }
            qw/copyResized copyResampled/
        ),
        imagemagick => sub {
            my $img = Image::Magick->new;
            $img->Read($srcfile);
            $img->Resize(
                width  => $width,
                height => $height,
            );
            $img->Write('imagemagick.jpg');
        },
        "imagemagick-lanczos" => sub {
            my $img = Image::Magick->new;
            $img->Read($srcfile);
            $img->Resize(
                width  => $width,
                height => $height,
                filter => 'Lanczos',
            );
            $img->Write('imagemagick-lanczos.jpg');
        }
    }
);



( run in 0.480 second using v1.01-cache-2.11-cpan-beeb90c9504 )