Skip Menu |

This queue is for tickets about the Apache2-Imager-Resize CPAN distribution.

Report information
The Basics
Id: 49805
Status: resolved
Priority: 0/
Queue: Apache2-Imager-Resize

People
Owner: Nobody in particular
Requestors: jozef [...] kutej.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.12
Fixed in: 0.14



Subject: patch to add scale type property
Hi Alex, this is a patch to be able to pass scale type value to Imager - http://search.cpan.org/perldoc?Imager::Transformations#scale Cheers, Jozef
Subject: Apache2-Imager-Resize-0.12-scaletype.patch
diff --git a/lib/Apache2/Imager/Resize.pm b/lib/Apache2/Imager/Resize.pm index 03f7f7c..ea949dd 100644 --- a/lib/Apache2/Imager/Resize.pm +++ b/lib/Apache2/Imager/Resize.pm @@ -88,6 +88,10 @@ By default images won't images get scaled up. If you wan't to do this, set enlar Overrides the default behaviour of configuration parameter "ImgResizeCropToAspectRatio". +=head2 scaletype + +Scale type 'min', 'max', 'nonprop'. See L<http://search.cpan.org/perldoc?Imager::Transformations#scale>. + =head1 CONFIGURATION In many cases, this will suffice: @@ -234,6 +238,7 @@ sub handler { $img_args{proportional} = $r->param('proportional'); $img_args{proportional} = 1 if not defined $img_args{proportional} or $img_args{proportional} eq ''; my $quality = $r->param('quality') || $default_quality; + $img_args{scale_type} = $r->param('scaletype'); my $shrunk; my ($name, $path, $suffix) = File::Basename::fileparse( $filename, '\.\w{2,5}' ); @@ -267,6 +272,10 @@ sub handler { $shrunk .= "_cropAR"; } + if ($img_args{scale_type}) { + $shrunk .= "_scaletype".$img_args{scale_type}; + } + $shrunk .= $suffix; if (file_ok( $shrunk, $filename )) { @@ -353,12 +362,27 @@ sub resize { } # enlarge images only if the enlarge argument is set - if ( not $args->{enlarge} and - ( ( $scale{xpixels} and ($scale{xpixels} > $imgwidth) ) - or ( $scale{ypixels} and ($scale{ypixels} > $imgheight) ) ) ) { + if ( + not $args->{enlarge} + and ( + ( $scale{xpixels} and ($scale{xpixels} > $imgwidth) ) + or ( $scale{ypixels} and ($scale{ypixels} > $imgheight) ) + ) + and ( + ($args->{scale_type} ne 'min') + or ( + ( $scale{xpixels} and ($scale{xpixels} > $imgwidth) ) + and ( $scale{ypixels} and ($scale{ypixels} > $imgheight) ) + ) + ) + ) { %scale = (); } + if ($args->{scale_type}) { + $scale{type} = $args->{scale_type}; + } + if ( not $args->{proportional} and $scale{xpixels} and $scale{ypixels} ) { $im = $im->scaleX(pixels=>$scale{xpixels})->scaleY(pixels=>$scale{ypixels}); }
patch applied to version 0.14