Image-Magick-Thumbnail-Fixed

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension Image::Magick::Thumbnail::Fixed.

0.01  Wed Aug 18 15:06:06 2004
	- original version; created by h2xs 1.22 with options
		-AX -n Image::Magick::Thumbnail::Fixed

0.04  Tues Apr 26 10:47:00 2005
  - Fixed resizing bug for sqaure images
  - Fixed debugging error that was carping too much
  

Fixed.pm  view on Meta::CPAN

package Image::Magick::Thumbnail::Fixed;

use 5.6.1;
use strict;
use warnings;
use Carp;

require Image::Magick;

our $VERSION = '0.04';

sub new {
  my $class = shift;  
  my $self = bless {}, $class;
}

sub debug {
  my $self = shift;
  $self->{debug} = shift;
}
 
sub thumbnail {
  my ($self, %args) = @_;
  
  my $im = new Image::Magick;
  
  # Required Parameters
  my $input   = $args{input};
  my $output  = $args{output};
  my $width   = $args{width};
  my $height  = $args{height};

  if( !$input ){
    carp "No input path specified";
    return undef;

Fixed.pm  view on Meta::CPAN


    warn "Ratio   : $ratio\n" if $self->{debug};
    warn "ThumbWH : $t_width x $t_height\n" if $self->{debug};      
  
    # Create thumbnail
    if( defined $im ){
      $im->Resize( width => $t_width, height => $t_height );
      $im->Set( quality => $quality );
      $im->Set( density => $density );
      
      my $thumb = new Image::Magick;
    
      $thumb->Set( size => $width . "x" . $height );
      $thumb->Set( quality => $quality );
      $thumb->Set( density => $density ); 
    
      $thumb->Read("gradient:$bgcolor-$bgcolor");
      
      $thumb->Composite( image   => $im, 
                         compose => $compose,
                         gravity => $gravity );

Fixed.pm  view on Meta::CPAN

  }
  return 1;
}

1;
__END__
# Below is stub documentation for your module. You'd better edit it!
 
=head1 NAME

Image::Magick::Thumbnail::Fixed - Perl extension for creating fixed sized thumbnails without distortion.

=head1 SYNOPSIS

  use Image::Magick::Thumbnail::Fixed;
  my $t = new Image::Magick::Thumbnail::Fixed;
  
  # Required parameters
  $t->thumbnail( input   => 'input.jpg',
                 output  => 'output.jpg',
                 width   => 96,
                 height  => 72 );
   
  # Required and optional parameters
  $t->thumbnail( input   => 'input.jpg',
                 output  => 'output.jpg',

Fixed.pm  view on Meta::CPAN

=head1 DESCRIPTION

Create fixed sized thumbnails without distorting or stretching the source image. 

Example: The source image is 349 x 324 (1.077 ratio). The thumbnail image is to be 96x72 (1.333 ratio).
Resizing the source image to 96 x 72 will cause distortion. This module will first resize the source in memory
(to 66 x 71) and then compose it ontop of the thumbnail canvas.

=head1 PREREQUISITES

C<Image::Magick>

=cut


=head2 REQUIRED PARAMETERS

=over 4

=item input

Fixed.pm  view on Meta::CPAN

Version 0.01 (18 August 2004): Initial Revision

Version 0.02 (31 August 2004): Perl 5.6.1 support, fixed height/width calculations that were broken in certain situations.

Version 0.03 (25 September 2004): made debug mode more verbose. Caught additional errors.

Version 0.04 (26 April 2005): Fixed debugging conditional that was too loud - pd <paul@dowling.id.au>, fixed bug with square images - Phillip Munt <phil@savvyshopper.net.au>.
 
=head1 SEE ALSO

L<Image::Magick>,
L<Image::Magick::Thumbnail>,
L<Image::Thumbnail>

=head1 AUTHOR

Adam Roth, E<lt>aroth@cpan.orgE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2004 by Adam Roth, all rights reserved.

Makefile.PL  view on Meta::CPAN

use 5.6.1;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    NAME              => 'Image::Magick::Thumbnail::Fixed',
    VERSION_FROM      => 'Fixed.pm', # finds $VERSION
    PREREQ_PM         => {}, # e.g., Module::Name => 1.1
    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM  => 'Fixed.pm', # retrieve abstract from module
       AUTHOR         => 'System Administrator <root@nonet>') : ()),
);



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