XAO-ImageCache

 view release on metacpan or  search on metacpan

ImageCache.pm  view on Meta::CPAN

###############################################################################
package XAO::ImageCache;
use strict;
use Error qw(:try);
use XAO::Utils;
use XAO::FS;
use XAO::Errors qw(XAO::ImageCache);
use Digest::MD5 qw(md5 md5_hex md5_base64);
use LWP::UserAgent;
use URI;
use Image::Magick;
use Date::Manip;
use File::Path;
use File::Copy;

use vars qw($VERSION);
$VERSION='1.22';

###############################################################################

##

ImageCache.pm  view on Meta::CPAN

    $label||='unknown';

    if(!$params) {
        dprint "Copying $infile to $outfile as is ($label)";
        copy($infile,$outfile);
        return;
    }

    my $geometry = ''; # image dimensions in ImageMagick geometry format

    my $image = Image::Magick->new() || $self->throw("- Image::Magick creation failure!");
    my $err   = $image->ReadImage($infile);
    ### dprint ".source in '$infile'";

    # Only throwing an error if no image was read. If we consider all
    # warnings as errors then some 3M tiff files don't parse.
    #
    # From http://www.imagemagick.org/script/perl-magick.php:
    #
    #   $x = $image->Read(...);
    #   warn "$x" if "$x";      # print the error message

ImageCache.pm  view on Meta::CPAN


Optional parameter cause image name in cache will be a MD5 Base64
digest of source image path where C<=> character removed, C<\> and C<+>
translated to C<_> and C<-> simultaniosely.

To get cached image name

=item size

- Prefered image size may set as C<geometry> equal to C<geometry> parameter
of Image::Magick module to pass it dirrectly to Image::Magick Scale function.

Other way to set the image size is set a width and height keys to preffered
values.

If one of image dimension is not defined then corresponding parameter of
original image will be used.

This way, image will be resized with same aspect ratio (same proportions) to
the original image if C<save_aspect_ratio> parameter present.

ImageCache.pm  view on Meta::CPAN

L<XAO::DO::FS::List>.

For additional information please see

L<XAO::DO::FS::Glue>,

L<XAO::DO::FS::Global>,

L<XAO::DO::FS::Glue::MySQL_DBI>,

Refer to L<Image::Magick> documentation for additional
information about setting of image scaling parameters.

Refer to L<LWP::UserAgent> documentation for additional
information about user agent parameters.

=head1 BUGS

Please, inform me about found bugs.

=head1 AUTHORS

META.json  view on Meta::CPAN

         }
      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "Date::Manip" : "6.22",
            "Image::Magick" : "v6.3.0",
            "LWP" : "5.63",
            "Test::Unit" : "0.14",
            "XAO::FS" : "1.01"
         }
      }
   },
   "release_status" : "stable",
   "version" : "1.22",
   "x_serialization_backend" : "JSON::PP version 4.04"
}

META.yml  view on Meta::CPAN

meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: XAO-ImageCache
no_index:
  directory:
    - t
    - inc
requires:
  Date::Manip: '6.22'
  Image::Magick: v6.3.0
  LWP: '5.63'
  Test::Unit: '0.14'
  XAO::FS: '1.01'
version: '1.22'
x_serialization_backend: 'CPAN::Meta::YAML version 0.011'

Makefile.PL  view on Meta::CPAN


WriteMakefile(
    'AUTHOR'        => 'Konstantin Safronov',
    'ABSTRACT'      => 'Images caching module for XAO::Commerce',
    'NAME'          => 'XAO::ImageCache',
    'VERSION_FROM'	=> 'ImageCache.pm',
    'PREREQ_PM'     => {
        'Date::Manip'   => '6.22',
	    'XAO::FS'	    => '1.01',
        'Test::Unit'    => '0.14',
	    'Image::Magick' => '6.3.0',
	    'LWP'		    => '5.63',
    },
    'MAN3PODS'      => \%man3pods,
);

sub MY::postamble {

    <<EOT;
config::	README

README  view on Meta::CPAN

        - data key for storing URL of image in cache.

        Optional parameter cause image name in cache will be a MD5 Base64
        digest of source image path where "=" character removed, "\" and "+"
        translated to "_" and "-" simultaniosely.

        To get cached image name

    size
        - Prefered image size may set as "geometry" equal to "geometry"
        parameter of Image::Magick module to pass it dirrectly to
        Image::Magick Scale function.

        Other way to set the image size is set a width and height keys to
        preffered values.

        If one of image dimension is not defined then corresponding
        parameter of original image will be used.

        This way, image will be resized with same aspect ratio (same
        proportions) to the original image if "save_aspect_ratio" parameter
        present.

README  view on Meta::CPAN

    XAO::DO::FS::List.

    For additional information please see

    XAO::DO::FS::Glue,

    XAO::DO::FS::Global,

    XAO::DO::FS::Glue::MySQL_DBI,

    Refer to Image::Magick documentation for additional information about
    setting of image scaling parameters.

    Refer to LWP::UserAgent documentation for additional information about
    user agent parameters.

BUGS
    Please, inform me about found bugs.

AUTHORS
    The XAO::ImageCache package maintained by Konstantin Safronov



( run in 0.492 second using v1.01-cache-2.11-cpan-beeb90c9504 )