Apache-Imager-Resize
view release on metacpan or search on metacpan
lib/Apache/Imager/Resize.pm view on Meta::CPAN
package Apache::Imager::Resize;
use strict;
use File::Basename ();
use File::Path ();
use Apache::Constants (':common');
use Imager;
use Data::Dumper;
use Apache::ModuleConfig ();
use DynaLoader ();
use vars qw($VERSION);
$VERSION = '0.11';
if($ENV{MOD_PERL}) {
no strict;
push @ISA, 'DynaLoader';
__PACKAGE__->bootstrap($VERSION);
}
=head1 NAME
Apache::Imager::Resize - Fixup handler that resizes and crops images on the fly, caching the results, and doesn't require ImageMagick.
=head1 SYNOPSIS
<Files "*.jpg">
PerlFixupHandler Apache::Imager::Resize
ImgResizeCacheDir '/imgcache'
</Files>
# or
<Location "/liveimages">
PerlHandler Apache::Imager::Resize
ImgResizeNoCache on
ImgResizeWidthParam 'w'
ImgResizeHeightParam 'h'
</Location>
# and on a web page somewhere:
<img src="image.jpg?w=300&h=200" width="300" height="200">
=head1 INTRODUCTION
This is a simple fixup class that only does one job: it resizes images before they're delivered. All you have to do is append either a width and/or a height parameter to any image file address, and AIR will make sure that an appropriately shrunken im...
There are other modules that you could do this with: see the links at the bottom of this pod. If your requirements might include more complicated transformations, or you're running mod_perl behind a thin proxy, you're probably better off with L<Apach...
The handler uses Imager to do the work. I intend to produce a proper general-purpose Apache::Imager package, if nobody else does, so this will end up being a special case with a simplified interface, and will probably live alongside an Apache::Imager...
=head1 PARAMETERS
Apache::Imager::Resize understands four query string parameters:
=head2 w
width in pixels. You can specify another name with an ImgResizeWidthParam directive.
=head2 h
height in pixels. BYou can specify another name with an ImgResizeHeightParam directive.
=head2 reshape
If this is 'crop', we will crop without resizing. The default behaviour is to scale first and then crop to fit the other dimension (see below). If only one dimension is specified, this parameter has no effect. There will be more options here in later...
( run in 2.053 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )