Apache::ImageShoehorn - mod_perl wrapper for Image::Shoehorn


  <Directory /path/to/some/directory/with/images>
   SetHandler   perl-script
   PerlHandler  Apache::ImageShoehorn

   PerlSetVar   ScaledDir       /path/to/some/dir

   PerlSetVar   SetScaleSmall   25%
   PerlSetVar   SetScaleMedium  50%
   PerlSetVar   SetScaleLarge   75%
   PerlSetVar   SetScaleThumb   x50

   PerlSetVar   SetValid        png
   PerlSetVar   Convert         On

   PerlSetVar   ScaleAllOnCleanup  Off

   <FilesMatch "\.html$">
    # Do something with HTML files here

  # This image would actually be converted and
  # sent to the browser as a PNG file. Woot!


Apache mod_perl wrapper for Image::Shoehorn.


  • ScaledDir string

    A path on the filesystem where the handler will save images that have been scaled

    Remember, this directory needs to be writable by whatever user is running the http daemon.

  • SetScaleName string

    Define the names and dimensions of scaled images. name will be converted to lower-case and compared with the scale CGI query parameter. If no matching config directive is located, the handler will return DECLINED.

    If there are multiple SetScale directives then they will be processed, if necessary, during the handler's cleanup stage.

    If a scaled image already exists, it will not be rescaled until the lastmodified time for the source file is greater than that of the scaled version.

    Valid dimensions are identical as those listed in Image::Shoehorn.

  • SetValid string

    Define one or more file types that are considered valid for sending to the browser, notwithstanding any issues of scaling, "as-is".

  • Convert (On|Off)

    If an image fails a validity test, then the image will be be converted using the first type defined by the SetValid configs that the package (read: Image::Magick) can understand.

  • ScaleAllOnCleanup (On|Off)

    Toggle setting for scaling all size definitions for an image during the cleanup phase of a request. Default is "On".

This package does not support all of the options available to the Image::Shoehorn constructor. They will likely be added in later releases. The current list of unsupported configuration options is :

  • max_height

  • max_width

  • overwrite




July 07, 2002


Aaron Straup Cope




Copyright (c) 2002 Aaron Straup Cope. All Rights Reserved.

This is free software, you may use it and distribute it under the same terms as Perl itself.