Apache-ImageMagick
view release on metacpan or search on metacpan
ImageMagick.pm view on Meta::CPAN
##
##--------------------------------------------------------------------------
package Apache::ImageMagick ;
use strict;
use vars qw{$VERSION %scriptmtime %scriptsub $packnum $debug} ;
use Image::Magick ();
use File::Basename qw(fileparse);
use DirHandle ();
use Digest::MD5 ;
use Text::ParseWords ;
$VERSION = '2.0b7' ;
# define constants here instead of use Apache::Constants qw(:common);to remove dependency
use constant OK => 0 ;
use constant NOT_FOUND => 404 ;
ImageMagick.pm view on Meta::CPAN
$r -> log_error ("Apache::ImageMagick: Source: $source Script: $script Cachefile: $cachepath") if ($debug) ;
#$r->send_http_header;
#return OK if $r->header_only;
# Read the image
my $q = Image::Magick->new;
my $err ;
$err = $q->Read($source) if (!$arguments{-new}) ;
my $errfilter ;
execute_script ($script, $r, $q, \@filters, \%arguments) or return SERVER_ERROR if ($script) ;
execute_script ($scriptdef, $r, $q, \@filters, \%arguments) or return SERVER_ERROR if ($scriptdef) ;
if ($param)
{
my @arglist = quotewords ('\s+', 0, $param) ;
ImageMagick.pm view on Meta::CPAN
</Location>
Then request
http://localhost/images/whatever.gif/Annotate?font=Arial&x=5&gravity=west&text=Hello+world+!
http://localhost/images/whatever.jpg
=head1 DESCRIPTION
This module uses the Image::Magick library to process an image on the fly.
It is able to convert the source image to any type you request that is supported
by Image::Magick (e.g. TIFF, PPM, PGM, PPB, GIF, JPEG and more). The requested
fileformat is determinated by the fileextention of the request and
Apache::ImageMagick will search for an image with the same basename and convert it
automaticly (unless you set C<AIMDisableSearch>).
Addtionaly you can specify (multiple) image manipulation filters in the additional path info,
and format options in the query string. All filters applied in the order they apear in
the path info. A list of available filters can be found at
http://www.imagemagick.org/www/perl.html#mani . As of this writing there are 67 very
powerfull filters available.
The parameters you give in the URL are passed to all filters. So the URL
ImageMagick.pm view on Meta::CPAN
in the directory given by C<AIMScriptDir>. So if C<AIMScriptDir> is set to
F</usr/images/scripts> and a request for F<whatever.gif> comes in, Apache::ImageMagick
looks for a script named F</usr/images/scripts/whatever.gif.pl>. If the script is
found it is loaded into memory, compiled and executed. If the script is already in
memory, Apache::ImageMagick checks if the scripts is modified and if not it is only
executed, so the Perl code has to be compiled only when the script changes.
If C<AIMScriptDir> is not set, Apache::ImageMagick doesn't search for a per image
script. There is a second sort of script the default one. The full path of this script
is specfied by the C<AIMScriptDefault> directive and is executed after the per image
script was executed. So it is able to force some default values.
Both sort of scripts takes four parameters. The Apache request record, the Image::Magick
object of the loaded image, an arrayref which contains the names of all filters and a
hashref that contains all arguments. You can use the Apache object to retrives any
information about the request. You can make any operation on the image object and you
can modify the filters and arguments parameters. Here is an example that forces any fontname
to be searched in a certain directory with the extention ttf. This actualy causes
Image::Magick to use true type fonts:
use constant FONTPATH => '/usr/images/fonts/' ;
use constant FONTDEFAULT => 'arial' ;
my ($r, $image, $filters, $args) = @_ ;
my $font ;
if ($args->{font})
{
ImageMagick.pm view on Meta::CPAN
Based on work from Lincoln Stein and Doug MacEachern publish in
"Writing Apache Modules with Perl and C" see www.modperl.com
=head1 SEE ALSO
=over 4
=item Perl(1)
=item Image::Magick
=item http://perl.apache.org
=item http://www.modperl.com
=back
## MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
## $Id: README,v 1.4 2001/08/13 06:52:57 richter Exp $
##
##--------------------------------------------------------------------------
Apache::ImageMagick - Convert and manipulate images on the fly
==============================================================
This module uses the Image::Magick library to process or create an image on
the fly. It is able to convert the source image to any type you request that
is supported by Image::Magick (e.g. TIFF, PPM, PGM, PPB, GIF, JPEG and more).
Additionaly you can specify (multiple) image manipulation filters in the
additional path info and format options in the query string.
Apache::ImageMagick caches the result image so multiple requested with
the same parameters only needs one computation. To do more sophisticated
manipulation, Apache::ImageMagick can run a script that does the image
manipulation/creation. Last but not least Apache::ImageMagick comes with
a proxy module, that can be linked into a non mod_perl frontend proxy server
and which will delivers cached images which highest possible speed.
For detailed information see
( run in 0.505 second using v1.01-cache-2.11-cpan-beeb90c9504 )