Image-Shoehorn
view release on metacpan or search on metacpan
Revision history for Perl extension Image::Shoehorn
$Id: Changes,v 1.9 2003/05/30 22:51:06 asc Exp $
1.42 Fri May 30 2003
- _ping() method taught to use File::MMagic to determine the
image's contenttype. (Image::Magick doesn't always return an
'image/foo-bar' string for an image's 'format'.)
- The 'type' attribute in hash ref returned by import() is
deprecated in favour of new 'extension' attribute.
- Added 'contenttype' attribute to hash ref returned by
import() method.
- Added requirement for Test::More in Makefile.PL
- Downgraded requirements for Image::Magick to 5.44
- Replaced test.pl with t/import.t
- Updated POD
1.41 Thu Aug 01 2002
- Added test in &scaled_dimensions to catch divide by zero errors
1.4 Sun Jul 21 2002
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'Image::Shoehorn',
($[ >= 5.005) ?
(AUTHOR => 'Aaron Straup Cope (cpan@aaronland.net)',
ABSTRACT => '') : (),
'VERSION_FROM' => 'lib/Image/Shoehorn.pm',
'PREREQ_PM' => {
Image::Magick => '5.44',
Error => '0',
File::Basename => '0',
File::MMagic => '1.16',
Carp => '0',
# For t/*.t
Test::More => '0',
Cwd => '0',
},
dist => {COMPRESS => 'gzip', SUFFIX => 'tar.gz'},
lib/Apache/ImageShoehorn.pm view on Meta::CPAN
=item *
SetValid I<string>
Define one or more file types that are considered valid for sending to the browser, notwithstanding any issues of scaling, "as-is".
=item *
Convert I<(On|Off)>
If an image fails a validity test, then the image will be be converted using the first type defined by the I<SetValid> configs that the package (read: Image::Magick) can understand.
=item *
ScaleAllOnCleanup I<(On|Off)>
Toggle setting for scaling all size definitions for an image during the cleanup phase of a request. Default is "On".
=back
This package does not support all of the options available to the I<Image::Shoehorn> constructor. They will likely be added in later releases. The current list of unsupported configuration options is :
lib/Apache/ImageShoehorn.pm view on Meta::CPAN
$apache->content_type() =~ /^(.*)\/(.*)$/;
if (! $2) { return 0; }
if (exists($TYPES{$apache->location()}->{$2})) {
return $TYPES{$apache->location()}->{$2};
}
if (! @FORMATS) {
@FORMATS = Image::Magick->QueryFormat();
}
$TYPES{$apache->location()}->{$2} = grep(/^($2)$/,@FORMATS);
return $TYPES{$apache->location()}->{$2};
}
sub _scalepath {
my $apache = shift;
my $scaled = Image::Shoehorn->scaled_name($_[0]);
lib/Image/Shoehorn.pm view on Meta::CPAN
overwrite => 1,
}) || die Image::Shoehorn->last_error();
print &Dumper($imgs);
=head1 DESCRIPTION
Image::Shoehorn will massage the dimensions and filetype of an image,
optionally creating one or more "scaled" copies.
It uses Image::Magick to do the heavy lifting and provides a single
"import" objet method to hide a number of tasks from the user.
=head1 RATIONALE
Just before I decided to submit this package to the CPAN, I noticed that
Lee Goddard had just released Image::Magick::Thumbnail. Although there is
a certain amount of overlap, creating thumbnails is only a part of the
functionality of Image::Shoehorn.
Image::Shoehorn is designed for taking a single image, optionally converting
its file type and resizing it, and then creating one or more "scaled"
versions of the (modified) image.
One example would be a photo-gallery application where the gallery may define
(n) number of scaled versions. In a mod_perl context, if the scaled image had
not already been created, the application might create the requested image
lib/Image/Shoehorn.pm view on Meta::CPAN
$Image::Shoehorn::VERSION = '1.42';
use File::Basename;
use Carp;
use Error;
# use Data::Dumper;
use Image::Magick 5.44;
use File::MMagic;
=head1 PACKAGE METHODS
=cut
=head2 __PACKAGE__->last_error()
Returns the last error recorded by the object.
lib/Image/Shoehorn.pm view on Meta::CPAN
$self->last_error("Unable to locate tmp dir");
return 0;
}
if (($args->{'cleanup'}) && (ref($args->{'cleanup'}) ne "CODE")) {
$self->last_error("Cleanup is not a code reference.");
return 0;
}
if (! $self->_magick()) {
$self->last_error("Unable to get Image::Magick : $!");
return 0;
}
$self->{'__cleanup'} = $args->{'cleanup'};
$self->{'__tmpdir'} = $args->{'tmpdir'};
return 1;
}
=head1 OBJECT METHODS
lib/Image/Shoehorn.pm view on Meta::CPAN
flags.
Scaled images are created in the I<tmp_dir> defined in the object constructor.
=item *
B<valid>
Array reference.
An list of valid file-types for which I<Image::Magick> has encoding support.
=item *
B<convert>
Boolean.
If this value is true and the source does not a valid file-type, the method
will create a temporary file attempt to convert it to one of the specified
valid file-types. The method will try to convert in the order the valid
lib/Image/Shoehorn.pm view on Meta::CPAN
return $self->{'__mmagic'};
}
# =head2 $obj->_magick()
#
# =cut
sub _magick {
my $self = shift;
if (ref($self->{'__magick'}) ne "Image::Magick") {
$self->{'__magick'} = Image::Magick->new();
}
return $self->{'__magick'};
}
# =head2 $obj->DESTROY()
#
# =cut
sub DESTROY {
lib/Image/Shoehorn.pm view on Meta::CPAN
Modify I<import> to accept multiple files.
=item *
Modify I<import> to accept strings and filehandles.
=back
=head1 SEE ALSO
L<Image::Magick>
L<Image::Magick::Thumbnail>
=head1 LICENSE
Copyright (c) 2001-2003, Aaron Straup Cope. All Rights Reserved.
This is free software, you may use it and distribute it under the same
terms as Perl itself.
=cut
( run in 0.298 second using v1.01-cache-2.11-cpan-beeb90c9504 )