Imager::Simple - Make easy things easy with Imager |
Imager::Simple - Make easy things easy with Imager
Version 0.010003
Imager::Simple
simplyfies common tasks with Imager.
use Imager::Simple;
# scale image "anim.gif" and assign output to a variable $scaled_data = eval { Imager::Simple->read('anim.gif')->scale(100, 100, 'min')->data; }; if ($@) { die "error from Imager::Simple: $@"; }
Imager is a powerful module for processing image data, but it is the power that makes it sometimes hard to use for simple tasks, like for example read an image, scale it, convert it to another format and save it somewhere. This module tries to DWIM with as little effort as possible.
$img = Imager::Simple->read($source, $type);
A constructor method that reads an image and returns an Image::Simple
object. $source
can be
The $type
is optional. If given it must be an image type known by
Imager like png
or jpeg
. If not given Imager tries to guess the
image type.
Image data is read by Imager's read_multi() method.
The returned object provides the individual images through the frames
method. For most images $img->frames
is a reference to an array
with one element (@{$img->frames} == 1
).
$img->format('gif');
Accessor to the image's output format.
Imager::Simple
supports multi-image files, e.g. GIF animations.
The individual images are stored in an array of Image objects,
that is available through the frames
method.
TODO
$scaled_img = $img->scale(100); $scaled_img = $img->scale({y => 100}); $scaled_img = $img->scale(100, 100, 'min'); $scaled_img = $img->scale(100, 100, {type => 'min'}); $scaled_img = $img->scale('min', {height => 100, width => 100});
Scale the image in place.
Accepts absolute and named arguments. Named arguments must be supplied
a hash reference as last argument. The order of absolute argument
positions is width
, height
, type
. All other arguments can only
be supplied as named arguments.
Possible names for the image width are width
, x
and xpixels
-
names for the image height are height
, y
and ypixels
- and
finally the type must be named type
. For all other known named
arguments see Imager::Transformations.
Absolute and named arguments can be mixed, whereas absolute arguments supersede named ones.
Image tags are copied from the old image(s)
where applicable.
$img->write($destination);
Write image data to given destination.
$destination
can be:
binmode
.
Returns the raw image data.
Bernhard Graf <graf at cpan.org>
This module definitely needs more work. It only implements some basic functionality (read, scale, write). No test have been written.
Please report any bugs or feature requests to
bug-imager-simple at rt.cpan.org
, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Imager::Simple
You can also look for information at:
Copyright 2007 - 2010 Bernhard Graf.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Imager::Simple - Make easy things easy with Imager |