|
Lines 74-81
sub new {
Link Here
|
| 74 |
sub _scale_image { |
74 |
sub _scale_image { |
| 75 |
my ( $self, $image, $maxwidth, $maxheight ) = @_; |
75 |
my ( $self, $image, $maxwidth, $maxheight ) = @_; |
| 76 |
my ( $width, $height ) = $image->getBounds(); |
76 |
my ( $width, $height ) = $image->getBounds(); |
| 77 |
$image->alphaBlending(0); |
77 |
$image->alphaBlending(0); |
| 78 |
$image->saveAlpha(1); |
78 |
$image->saveAlpha(1); |
| 79 |
if ( $width > $maxwidth || $height > $maxheight ) { |
79 |
if ( $width > $maxwidth || $height > $maxheight ) { |
| 80 |
|
80 |
|
| 81 |
my $percent_reduce; # Percent we will reduce the image dimensions by... |
81 |
my $percent_reduce; # Percent we will reduce the image dimensions by... |
|
Lines 87-94
sub _scale_image {
Link Here
|
| 87 |
} |
87 |
} |
| 88 |
my $width_reduce = sprintf( "%.0f", ( $width * $percent_reduce ) ); |
88 |
my $width_reduce = sprintf( "%.0f", ( $width * $percent_reduce ) ); |
| 89 |
my $height_reduce = sprintf( "%.0f", ( $height * $percent_reduce ) ); |
89 |
my $height_reduce = sprintf( "%.0f", ( $height * $percent_reduce ) ); |
| 90 |
my $newimage = GD::Image->new( $width_reduce, $height_reduce, 1 ) |
90 |
my $newimage = GD::Image->new( $width_reduce, $height_reduce, 1 ); #'1' creates true color image... |
| 91 |
; #'1' creates true color image... |
|
|
| 92 |
$newimage->alphaBlending(0); |
91 |
$newimage->alphaBlending(0); |
| 93 |
$newimage->saveAlpha(1); |
92 |
$newimage->saveAlpha(1); |
| 94 |
$newimage->copyResampled( $image, 0, 0, 0, 0, $width_reduce, $height_reduce, $width, $height ); |
93 |
$newimage->copyResampled( $image, 0, 0, 0, 0, $width_reduce, $height_reduce, $width, $height ); |