Image-Magick-Thumbnail-Simple

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

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

0.01  Wed Apr  2 23:28:43 2008
	- original version; created by h2xs 1.23 with options
		-XA Image::Magick::Thumbnail::Simple

Makefile.PL  view on Meta::CPAN

use 5.008008;
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::Simple',
    VERSION_FROM      => 'lib/Image/Magick/Thumbnail/Simple.pm', # finds $VERSION
    PREREQ_PM         => {}, # e.g., Module::Name => 1.1
    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM  => 'lib/Image/Magick/Thumbnail/Simple.pm', # retrieve abstract from module
       AUTHOR         => 'root <root@localdomain>') : ()),
);

lib/Image/Magick/Thumbnail/Simple.pm  view on Meta::CPAN

package Image::Magick::Thumbnail::Simple;

use 5.008008;
use strict;
use warnings;

our $VERSION = '0.12';

require Image::Magick;

	my $error = q{};

#-------------------------------------------------------------------------------
# Module declaration
#-------------------------------------------------------------------------------
sub new {
	my $proto = shift;
	my %argv = @_;
	my $class = ref( $proto ) || $proto;

lib/Image/Magick/Thumbnail/Simple.pm  view on Meta::CPAN

	# size
	if( !$size ){
		$error = 'No size or scale specified';
		return;
	}
	elsif( $size <= 0 ){
		$error = 'Invalid width';
		return;
	}

	my $image = new Image::Magick;

	$image -> Read( $input );
	my( $width, $height ) = $image -> Ping( $input );

	# horizonal
	if( $width > $height ){
		$self -> {HEIGHT} = int( $height * ( $size / $width ) );
		$self -> {WIDTH} = $size;
	}

lib/Image/Magick/Thumbnail/Simple.pm  view on Meta::CPAN

}

# Preloaded methods go here.

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

=head1 NAME

Image::Magick::Thumbnail::Simple - The thumbnail image is easily made without uselessness.

=head1 SYNOPSIS

=head2 It outputs it to the file. 

  use Image::Magick::Thumbnail::Simple;
  my $t = new Image::Magick::Thumbnail::Simple;
  $t -> thumbnail(
    input  => 'input.jpg',
    output => 'output.jpg',
    size   => 128,
  ) or die $t -> error;

=head2 It outputs it to the STDOUT. 

  use Image::Magick::Thumbnail::Simple;
  my $t = new Image::Magick::Thumbnail::Simple;
  binmode STDOUT;
  print "Content-type: image/jpeg\n\n";
  $t -> thumbnail(
    input  => 'input.jpg',
    output => 'jpg:-',
    size   => 128,
  ) or die $t -> error;

=head2 When specifying it when initializing it

It is succeeded to as long as it doesn't individually specify it at all the 
following. 

  $t = new Image::Magick::Thumbnail::Simple(
    size    => 128,
    blur    => 0.8,
    quality => 80,
  );

=head2 When changing

It is effective for jpeg format. 
The value is between from 0 to 100. 

lib/Image/Magick/Thumbnail/Simple.pm  view on Meta::CPAN

=head2 Width of thumbnail image

  $width = $t -> width;

=head2 Height of thumbnail image

  $height = $t -> height;

=head1 DESCRIPTION

The thumbnail image can be easily made by using Image::Magick.
A basic setting is the same as Image::Magick.
Only the processing of the resize of the image is treated.
The version opened to the public is 0.10.
In 0.12, it came to return a size that corrected of the explanation 
and was thumbnail.

=head1 SEE ALSO

Image::Magick

=head1 AUTHOR

Satoshi Ishikawa E<lt>cpan@penlabo.netE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2008 Satoshi Ishikawa

This library is free software; you can redistribute it and/or modify

t/Image-Magick-Thumbnail-Simple.t  view on Meta::CPAN

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Image-Magick-Thumbnail-Simple.t'

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

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More tests => 1;
BEGIN { use_ok('Image::Magick::Thumbnail::Simple') };

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

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.



( run in 0.681 second using v1.01-cache-2.11-cpan-2b0bae70ee8 )