CGI::Application::PhotoGallery::Magick - Image::Magick-based graphics adaptor


CGI-Application-PhotoGallery documentation Contained in the CGI-Application-PhotoGallery distribution.

Index


Code Index:

NAME

Top

CGI::Application::PhotoGallery::Magick - Image::Magick-based graphics adaptor

SYNOPSIS

Top

    use CGI::Application::PhotoGallery::Magick;

    my $lib     = CGI::Application::PhotoGallery::Magick->new;
    my $pngdata = $lib->resize( $file, 100 );

METHODS

Top

new( )

creates a new CGI::Application::PhotoGallery::Magick object.

resize( $file, $size )

Resizes $file to $sizex$size with transparent margins.

load( $file )

Loads $file and returns a GD::Image.

size( $file )

Returns the width and height of $file.

SEE ALSO

Top

* Image::Magick

AUTHOR

Top

Brian Cassidy <bricas@cpan.org>

COPYRIGHT AND LICENSE

Top


CGI-Application-PhotoGallery documentation Contained in the CGI-Application-PhotoGallery distribution.
package CGI::Application::PhotoGallery::Magick;

use strict;
use warnings;

use Image::Magick;

our $VERSION = '0.15';

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

sub resize {
    my $self = shift;
    my $file = shift;
    my $size = shift;

    my $image = $self->load( $file );

    $image->Scale( Geometry => $size . "x$size" );

    return $image->ImageToBlob( magick => 'png' );
}

sub load {
    my $self = shift;
    my $file = shift;

    my $image = Image::Magick->new;

    $image->Read( $file );

    return $image;
}

sub size {
    my $self = shift;
    my $file = shift;

    my $image = $self->load( $file );

    return $image->Get( 'width', 'height' );
}

1;