NAME
Imager - Perl extension for Generating 24 bit Images
SYNOPSIS
# Thumbnail example
#!/usr/bin/perl -w
use strict;
use Imager;
die "Usage: thumbmake.pl filename\n" if !-f $ARGV[0];
my $file = shift;
my $format;
my $img = Imager->new();
# see Imager::Files for information on the open() method
$img->open(file=>$file) or die $img->errstr();
$file =~ s/\.[^.]*$//;
# Create smaller version
# documented in Imager::Transformations
my $thumb = $img->scale(scalefactor=>.3);
# Autostretch individual channels
$thumb->filter(type=>'autolevels');
# try to save in one of these formats
SAVE:
for $format ( qw( png gif jpg tiff ppm ) ) {
# Check if given format is supported
if ($Imager::formats{$format}) {
$file.="_low.$format";
print "Storing image as: $file\n";
# documented in Imager::Files
$thumb->write(file=>$file) or
die $thumb->errstr;
last SAVE;
}
}
DESCRIPTION
Imager is a module for creating and altering images. It can read and write various image formats, draw primitive shapes like lines,and polygons, blend multiple images together in various ways, scale, crop, render text and more.
Overview of documentation
Imager - This document - Synopsis Example, Table of Contents and Overview.
Imager::ImageTypes - Basics of constructing image objects with
new()
: Direct type/virtual images, RGB(A)/paletted images, 8/16/double bits/channel, color maps, channel masks, image tags, color quantization. Also discusses basic image information methods.Imager::Files - IO interaction, reading/writing images, format specific tags.
Imager::Draw - Drawing Primitives, lines, boxes, circles, arcs, flood fill.
Imager::Color - Color specification.
Imager::Fill - Fill pattern specification.
Imager::Font - General font rendering, bounding boxes and font metrics.
Imager::Transformations - Copying, scaling, cropping, flipping, blending, pasting, convert and map.
Imager::Engines - Programmable transformations through
transform()
,transform2()
andmatrix_transform()
.Imager::Filters - Filters, sharpen, blur, noise, convolve etc. and filter plugins.
Imager::Expr - Expressions for evaluation engine used by transform2().
Imager::Matrix2d - Helper class for affine transformations.
Imager::Fountain - Helper for making gradient profiles.
Basic Overview
An Image object is created with $img = Imager->new()
. Examples:
$img=Imager->new(); # create empty image
$img->open(file=>'lena.png',type=>'png') or # read image from file
die $img->errstr(); # give an explanation
# if something failed
or if you want to create an empty image:
$img=Imager->new(xsize=>400,ysize=>300,channels=>4);
This example creates a completely black image of width 400 and height 300 and 4 channels.
When an operation fails which can be directly associated with an image the error message is stored can be retrieved with $img->errstr()
.
In cases where no image object is associated with an operation $Imager::ERRSTR
is used to report errors not directly associated with an image object.
The Imager->new
method is described in detail in Imager::ImageTypes.
METHOD INDEX
Where to find information on methods for Imager class objects.
addcolors() - Imager::ImageTypes
addtag() - Imager::ImageTypes - add image tags
arc() - "arc" in Imager::Draw
bits() - Imager::ImageTypes - number of bits per sample for the image
box() - "box" in Imager::Draw
circle() - "circle" in Imager::Draw
convert() - "Color transformations" in Imager::Transformations - transform the color space
copy() - "copy" in Imager::Transformations
crop() - "crop" in Imager::Transformations - extract part of an image
deltag() - Imager::ImageTypes - delete image tags
difference() - "Image Difference" in Imager::Filters
filter() - Imager::Filters
findcolor() - Imager::ImageTypes - search the image palette, if it has one
flip() - "flip" in Imager::Transformations
flood_fill() - "flood_fill" in Imager::Draw
getchannels() - Imager::ImageTypes
getcolorcount() - Imager::ImageTypes
getcolors() - Imager::ImageTypes - get colors from the image palette, if it has one
getheight() - Imager::ImageTypes
getpixel() - "setpixel and getpixel" in Imager::Draw
getwidth() - Imager::ImageTypes
img_set() - Imager::ImageTypes
line() - "line" in Imager::Draw
map() - "Color Mappings" in Imager::Transformations - remap color channel values
masked() - Imager::ImageTypes - make a masked image
matrix_transform() - "Matrix Transformations" in Imager::Engines
new() - Imager::ImageTypes
paste() - "paste" in Imager::Transformations - draw an image onto an image
polygon() - "polygon" in Imager::Draw
polyline() - "polyline" in Imager::Draw
read() - Imager::Files
read_multi() - Imager::Files
rotate() - "rotate" in Imager::Transformations
rubthrough() - "rubthrough" in Imager::Transformations - draw an image onto an image and use the alpha channel
scale() - "scale" in Imager::Transformations
setcolors() - Imager::ImageTypes - set palette colors in a paletted image
setpixel() - "setpixel and getpixel" in Imager::Draw
string() - "string" in Imager::Font - draw text on an image
tags() - Imager::ImageTypes - fetch image tags
to_paletted() - Imager::ImageTypes
to_rgb8() - Imager::ImageTypes
transform() - "transform" in Imager::Engines
transform2() - "transform2" in Imager::Engines
type() - Imager::ImageTypes - type of image (direct vs paletted)
virtual() - Imager::ImageTypes - whether the image has it's own data
write() - Imager::Files
write_multi() - Imager::Files
SUPPORT
You can ask for help, report bugs or express your undying love for Imager on the Imager-devel mailing list.
To subscribe send a message with subscribe
in the body to:
imager-devel+request@molar.is
or use the form at:
http://www.molar.is/en/lists/imager-devel/
(annonymous is temporarily off due to spam)
where you can also find the mailing list archive.
If you're into IRC, you can typically find the developers in #Imager on irc.perl.org. As with any IRC channel, the participants could be occupied or asleep, so please be patient.
You can report bugs either by sending email to:
bug-Imager@rt.cpan.org
or by pointing your browser at:
https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Imager
Please remember to include the versions of Imager, perl, supporting libraries, and any relevant code. If you have specific images that cause the problems, please include those too.
BUGS
Bugs are listed individually for relevant pod pages.
AUTHOR
Arnar M. Hrafnkelsson (addi@imager.perl.org) and Tony Cook (tony@imager.perl.org) See the README for a complete list.
SEE ALSO
perl(1), Imager::ImageTypes(3), Imager::Files(3), Imager::Draw(3), Imager::Color(3), Imager::Fill(3), Imager::Font(3), Imager::Transformations(3), Imager::Engines(3), Imager::Filters(3), Imager::Expr(3), Imager::Matrix2d(3), Imager::Fountain(3)
Affix::Infix2Postfix(3), Parse::RecDescent(3) http://imager.perl.org/