GD::Image::Thumbnail - Perl extension for creating thumbnailed images with GD.
use GD::Image::Thumbnail; my $img = GD::Image->new(100,20); my $thm = $img->thumbnail; # same as { factor => 0.20 } my $thm = $img->thumbnail($n); # same as { side => $n } my $thm = $img->thumbnail({ factor => 0.25 }); my $thm = $img->thumbnail({ factor => 0.25, small => 1 }); my $thm = $img->thumbnail({ side => $n }); my $thm = $img->thumbnail({ side => $n, small => 1 }); my $thm = $img->thumbnail({ w => $w }); my $thm = $img->thumbnail({ h => $h }); my $thm = $img->thumbnail({ w => $w, h => $h }); my $thm = $img->thumbnail({ w => $w, small => 1 }); my $thm = $img->thumbnail({ h => $h, small => 1 }); my $thm = $img->thumbnail({ w => $w, h => $h, small => 1 });
thumb() is shortcut for thumbnail() - useful for people who like to bite their nails :)
$img->thumbnail(@thm_args)
and
$img->thumb(@thm_args);
are doing the same thing
This makes a thumbnail $n (0.20 by default) times the size of the original. Only a two decimal place number between 0 and 1 are allowed. If a factor is given side, h, and w are all ignored
Makes the side that will result in a larger thumbnail $n pixels (or opposite if small => 1). If side is given then h and w are ignored.
You can specify one or both of these. If only one is given it makes that side that dimention. If you specify both, the side that will result in a larger thumbnail (based on the image's orientation and *not* the values of w and h if different), is used (or opposite if small => 1).
If true make the images the smallest possible. This will round down instead of up when rounding is necessary and will help decide which side gets set to the given value.
$img->thumbnail(10); # 100 x 25 image becomes 40 x 10 $img->thumbnail({ side => 10, small => 1}); # 100 x 25 image becomes 10 x 2
If true use copyResampled() instead of copyResized() See GD's documentation about the difference. This can also be turned on by specifying a true value as the second argument:
$img->thumbnail($n, 1); $img->thumbnail({ factor => $n }, 1);
If called in scalar context it return the new GD::Image object that is the thumbnail (IE the original object is not modified)
my $thm = $img->thumb;
If called in array context it returns an array which is the new object, the width , and height of the new image in that object.
my($thm,$thm_w,$thm_h) = $img->thumb;
I'd like to add functionality to modify the original image object if called in void context:
$img->thumbnail(@thm_args);
GD
Daniel Muey, http://drmuey.com/cpan_contact.pl
Copyright 2005 by Daniel Muey
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install GD::Image::Thumbnail, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GD::Image::Thumbnail
CPAN shell
perl -MCPAN -e shell install GD::Image::Thumbnail
For more information on module installation, please visit the detailed CPAN module installation guide.