Imager(3pm)
π NAME π
okay so Imager(3pm) is the manual page for Imager β a Perl extension for Generating 24 bit Images. yes, capital G, capital I, icon behavior π
Itβs your bestie for creating and altering images: reading and writing formats, drawing, blending, scaling, cropping, rendering text, and more.
β¨ SYNOPSIS β¨
hereβs the thumbnail example, no cap:
# 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;
# see Imager::Files for information on the read() method
my $img = Imager->new(file=>$file)
or die Imager->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 jpeg 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. itβs giving βimage toolkit but make it Perlβ and honestly? obsessed π«Ά
π Overview of documentation π
Imagerβ this document right here: Synopsis, Example, Table of Contents and Overview. meta much? πImager::Installβ installation notes for Imager.Imager::Tutorialβ a brief introduction to Imager.Imager::Cookbookβ how to do various things with Imager.Imager::ImageTypesβ Basics of constructing image objects withnew(): 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 throughtransform(),transform2()andmatrix_transform().Imager::Filtersβ Filters, sharpen, blur, noise, convolve etc. and filter plug-ins.Imager::Exprβ Expressions for evaluation engine used bytransform2().Imager::Matrix2dβ Helper class for affine transformations.Imager::Fountainβ Helper for making gradient profiles.Imager::IOβ Imager I/O abstraction.Imager::APIβ using Imager's C APIImager::APIRefβ API function referenceImager::Inlineβ using Imager's C API fromInline::CImager::ExtUtilsβ tools to get access to Imager's C API.Imager::Securityβ brief security notes.Imager::Threadsβ brief information on working with threads.
π Basic Overview π
An Image object is created with $img = Imager->new(). Examples:
$img=Imager->new(); # create empty image
$img->read(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. little void-core moment, but make it fashion π€
π ERROR HANDLING π
In general a method will return false when it fails, if it does use the errstr() method to find out why:
π errstr() π
Returns the last error message in that context.
If the last error you received was from calling an object method, such as read, call errstr() as an object method to find out why:
my $image = Imager->new;
$image->read(file => 'somefile.gif')
or die $image->errstr;
If it was a class method then call errstr() as a class method:
my @imgs = Imager->read_multi(file => 'somefile.gif')
or die Imager->errstr;
Note that in some cases object methods are implemented in terms of class methods so a failing object method may set both. iykyk π
The Imager->new method is described in detail in Imager::ImageTypes.
π METHOD INDEX π
okay bestie so this is the master map β every method in the Imager universe and which module's docs actually explain it. think of it as the group chat directory: you got a name, you got the module they live in, and a one-line vibe check. click through, iykyk π
addcolors()βaddcolors()inImager::ImageTypesβ adds colors to a paletted imageadd_file_magic()βadd_file_magic()inImager::Filesβ adds magic to Imager's file type detectoraddtag()βaddtag()inImager::ImageTypesβ adds image tagsadd_type_extensions()βadd_file_magic()inImager::Filesβ adds magic for new image file typesadd_type_extensions($type, $ext, ...)β inImager::Filesβ adds extensions for new image file typesalign_string()βalign_string()inImager::Drawβ draws text aligned on a pointalphachannel()βalphachannel()inImager::ImageTypesβ returns the channel index of the alpha channel (if any)arc()βarc()inImager::Drawβ draws a filled arcbits()βbits()inImager::ImageTypesβ number of bits per sample for the imagebox()βbox()inImager::Drawβ draws a filled or outline boxcheck_file_limits()βcheck_file_limits()inImager::Filescircle()βcircle()inImager::Drawβ draws a filled circleclose_log()βclose_log()inImager::ImageTypesβ closes the Imager debugging logcolorchannels()βcolorchannels()inImager::ImageTypesβ the number of channels used for colorcolorcount()βcolorcount()inImager::ImageTypesβ the number of colors in an image's palette (paletted images only)colormodel()βcolorcount()inImager::ImageTypesβ how color is representedcombine()βcombine()inImager::Transformationsβ combines channels from one or more imagescombines()βcombines()inImager::Drawβ returns a list of the different combine type keywordscompose()βcompose()inImager::Transformationsβ composes one image over anotherconvert()βconvert()inImager::Transformationsβ transforms the color spacecopy()βcopy()inImager::Transformationsβ makes a duplicate of an imagecrop()βcrop()inImager::Transformationsβ extracts part of an imagedef_guess_type()βdef_guess_type()inImager::Filesβ the default function used to guess the output file format based on the output file namedeltag()βdeltag()inImager::ImageTypesβ deletes image tagsdifference()βdifference()inImager::Filtersβ produces a difference images from two input imageserrstr()βerrstr()β the error from the last failed operationfilter()βfilter()inImager::Filtersβ image filteringfindcolor()βfindcolor()inImager::ImageTypesβ searches the image palette, if it has oneflip()βflip()inImager::Transformationsβ flips an image, vertically, horizontallyflood_fill()βflood_fill()inImager::Drawβ fills an enclosed or same color areagetchannels()βgetchannels()inImager::ImageTypesβ the number of samples per pixel for an imagegetcolorcount()βgetcolorcount()inImager::ImageTypesβ the number of different colors used by an image (works for direct color images)getcolors()βgetcolors()inImager::ImageTypesβ gets colors from the image palette, if it has onegetcolorusage()βgetcolorusage()inImager::ImageTypesgetcolorusagehash()βgetcolorusagehash()inImager::ImageTypesget_file_limits()βget_file_limits()inImager::Filesgetheight()βgetheight()inImager::ImageTypesβ height of the image in pixelsgetmask()βgetmask()inImager::ImageTypesβ write mask for the imagegetpixel()βgetpixel()inImager::Drawβ retrieves one or more pixel colorsgetsamples()βgetsamples()inImager::Drawβ retrieves samples from a row or partial row of pixelsgetscanline()βgetscanline()inImager::Drawβ retrieves colors for a row or partial row of pixelsgetwidth()βgetwidth()inImager::ImageTypesβ width of the image in pixelsimg_set()βimg_set()inImager::ImageTypesβ re-uses an Imager object for a new imageinit()βinit()inImager::ImageTypesis_bilevel()βis_bilevel()inImager::ImageTypesβ returns whether image write functions should write the image in their bilevel (blank and white, no gray levels) formatis_logging()βis_logging()inImager::ImageTypesβ tests if the debug log is activeline()βline()inImager::Drawβ draws an intervalload_plugin()βload_plugin()inImager::Filterslog()βlog()inImager::ImageTypesβ sends a message to the debugging logmake_palette()βmake_palette()inImager::ImageTypesβ produces a color palette from one or more input imagesmap()βmap()inImager::Transformationsβ remaps color channel valuesmasked()βmasked()inImager::ImageTypesβ makes a masked imagematrix_transform()βmatrix_transform()inImager::Enginesmaxcolors()βmaxcolors()inImager::ImageTypesNC()βNC()inImager::HandyNCF()βNCF()inImager::Handynew()βnew()inImager::ImageTypesnewcolor()βnewcolor()inImager::Handynewcolour()βnewcolour()inImager::Handynewfont()βnewfont()inImager::HandyNF()βNF()inImager::Handyopen()βread()inImager::Filesβ an alias forread()open_log()βopen_log()inImager::ImageTypesβ opens the debug logparseiptc()βparseiptc()inImager::Filesβ parses IPTC data from a JPEG imagepaste()βpaste()inImager::Transformationsβ draws an image onto an imagepolygon()βpolygon()inImager::Drawpolyline()βpolyline()inImager::Drawpolypolygon()βpolypolygon()inImager::Drawpreload()βpreload()inImager::Filesread()βread()inImager::Filesβ reads a single image from an image fileread_multi()βread_multi()inImager::Filesβ reads multiple images from an image fileread_types()βread_types()inImager::Filesβ lists image types Imager can readregister_filter()βregister_filter()inImager::Filtersregister_reader()βregister_reader()inImager::Filesregister_writer()βregister_writer()inImager::Filesrgb_difference()βrgb_difference()inImager::Filtersβ produces a difference images from two input imagesrotate()βrotate()inImager::Transformationsrubthrough()βrubthrough()inImager::Transformationsβ draws an image onto an image and uses the alpha channelscale()βscale()inImager::Transformationsscale_calculate()βscale_calculate()inImager::TransformationsscaleX()βscaleX()inImager::TransformationsscaleY()βscaleY()inImager::Transformationssetcolors()βsetcolors()inImager::ImageTypesβ sets palette colors in a paletted imageset_file_limits()βset_file_limits()inImager::Filessetmask()βsetmask()inImager::ImageTypessetpixel()βsetpixel()inImager::Drawsetsamples()βsetsamples()inImager::Drawsetscanline()βsetscanline()inImager::Drawsettag()βsettag()inImager::ImageTypesstring()βstring()inImager::Drawβ draws text on an imagetags()βtags()inImager::ImageTypesβ fetches image tagsto_paletted()βto_paletted()inImager::ImageTypesto_rgb16()βto_rgb16()inImager::ImageTypesto_rgb8()βto_rgb8()inImager::ImageTypesto_rgb_double()βto_rgb_double()inImager::ImageTypesβ converts to double per sample imagetransform()βtransform()inImager::Enginestransform2()βtransform2()inImager::Enginestrim()βtrim()inImager::Transformationsβ returns a cropped image based on border transparency or border colorstrim_rect()βtrim_rect()inImager::Transformationsβ returns how muchtrim()would removetype()βtype()inImager::ImageTypesβ type of image (direct vs paletted)unload_plugin()βunload_plugin()inImager::Filtersvirtual()βvirtual()inImager::ImageTypesβ whether the image has it's own datawrite()βwrite()inImager::Filesβ writes an image to a filewrite_multi()βwrite_multi()inImager::Filesβ writes multiple image to an image filewrite_types()βread_types()inImager::Filesβ lists image types Imager can write
pro tip bestie: a bunch of these cross-reference lines point at a different method name than the one you searched β like colormodel() sending you to colorcount(), or write_types() sending you to read_types(). that's not a typo on my end, that's literally what the docs say, so follow the breadcrumbs fr fr π«Ά
π CONCEPT INDEX π
okay so this is basically the group chat's "who's who" of Imager β you look up a thing you wanna do and it tells you which page has the tea. find your vibe, click through, slay π
- animated GIF β
"Writing an animated GIF" in Imager::Files - aspect ratio β
"i_xres","i_yres","i_aspect_only"in"Common Tags"inImager::ImageTypes. - blend β alpha blending one image onto another
"rubthrough()" in Imager::Transformations - blur β
""gaussian"" in Imager::Filters,""conv"" in Imager::Filters - boxes, drawing β
"box()" in Imager::Draw - changes between image β
"Image Difference" in Imager::Filters - channels, combine into one image β
"combine()" in Imager::Transformations - color β
Imager::Color - color names β
Imager::Color,Imager::Color::Table - combine modes β
"Combine Types" in Imager::Draw - compare images β
"Image Difference" in Imager::Filters - contrast β
""contrast"" in Imager::Filters,""autolevels"" in Imager::Filters - convolution β
""conv"" in Imager::Filters - cropping β
"crop()" in Imager::Transformations,"trim()" in Imager::Transformations - CUR files β
"ICO (Microsoft Windows Icon) and CUR (Microsoft Windows Cursor)" in Imager::Files - "diff" images β
"Image Difference" in Imager::Filters - dpi β
"i_xres","i_yres"in"Common Tags" in Imager::ImageTypes,"Image spatial resolution" in Imager::Cookbook - drawing boxes β
"box()" in Imager::Draw - drawing lines β
"line()" in Imager::Draw - drawing text β
"string()" in Imager::Draw,"align_string()" in Imager::Draw - error message β
"ERROR HANDLING" - files, font β
Imager::Font - files, image β
Imager::Files - filling, types of fill β
Imager::Fill - filling, boxes β
"box()" in Imager::Draw - filling, flood fill β
"flood_fill()" in Imager::Draw - flood fill β
"flood_fill()" in Imager::Draw - fonts β
Imager::Font - fonts, drawing with β
"string()" in Imager::Draw,"align_string()" in Imager::Draw,Imager::Font::Wrap - fonts, metrics β
"bounding_box()" in Imager::Font,Imager::Font::BBox - fonts, multiple master β
"MULTIPLE MASTER FONTS" in Imager::Font - fountain fill β
"Fountain fills" in Imager::Fill,""fountain"" in Imager::Filters,Imager::Fountain,""gradgen"" in Imager::Filters - GIF files β
"GIF" in Imager::Files - GIF files, animated β
"Writing an animated GIF" in Imager::Files - gradient fill β
"Fountain fills" in Imager::Fill,""fountain"" in Imager::Filters,Imager::Fountain,""gradgen"" in Imager::Filters - gray scale, convert image to β
"convert()" in Imager::Transformations - gaussian blur β
""gaussian"" in Imager::Filters,""gaussian2"" in Imager::Filters - hatch fills β
"Hatched fills" in Imager::Fill - ICO files β
"ICO (Microsoft Windows Icon) and CUR (Microsoft Windows Cursor)" in Imager::Files - invert image β
""hardinvert"" in Imager::Filters,""hardinvertall"" in Imager::Filters - JPEG β
"JPEG" in Imager::Files - limiting image sizes β
"Limiting the sizes of images you read" in Imager::Files - lines, drawing β
"line()" in Imager::Draw - matrix β
Imager::Matrix2d,"Matrix Transformations" in Imager::Engines,"transform()" in Imager::Font - metadata, image β
"Tags" in Imager::ImageTypes,Image::ExifTool - mosaic β
""mosaic"" in Imager::Filters - noise, filter β
""noise"" in Imager::Filters - noise, rendered β
""turbnoise"" in Imager::Filters,""radnoise"" in Imager::Filters - paste β
"paste()" in Imager::Transformations,"rubthrough()" in Imager::Transformations - pseudo-color image β
"to_paletted()" in Imager::ImageTypes,"new()" in Imager::ImageTypes - posterize β
""postlevels"" in Imager::Filters - PNG files β
Imager::Files,"PNG" in Imager::Files - PNM β
"PNM (Portable aNy Map)" in Imager::Files - rectangles, drawing β
"box()" in Imager::Draw - resizing an image β
"scale()" in Imager::Transformations,"crop()" in Imager::Transformations - RGB (SGI) files β
"SGI (RGB, BW)" in Imager::Files - saving an image β
Imager::Files - scaling β
"scale()" in Imager::Transformations - security β
Imager::Security - SGI files β
"SGI (RGB, BW)" in Imager::Files - sharpen β
""unsharpmask"" in Imager::Filters,""conv"" in Imager::Filters - size, image β
"getwidth()" in Imager::ImageTypes,"getheight()" in Imager::ImageTypes - size, text β
"bounding_box()" in Imager::Font - tags, image metadata β
"Tags" in Imager::ImageTypes - text, drawing β
"string()" in Imager::Draw,"align_string()" in Imager::Draw,Imager::Font::Wrap - text, wrapping text in an area β
Imager::Font::Wrap - text, measuring β
"bounding_box()" in Imager::Font,Imager::Font::BBox - threads β
Imager::Threads - tiles, color β
""mosaic"" in Imager::Filters - transparent images β
Imager::ImageTypes,"Transparent PNG" in Imager::Cookbook - unsharp mask β
""unsharpmask"" in Imager::Filters - watermark β
""watermark"" in Imager::Filters - writing an image to a file β
Imager::Files
π«Ά SUPPORT π«Ά
bestie, if you're stuck, the mailing list is genuinely the best place to get help with Imager. that's the main character of support channels, no cap.
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/
where you can also find the mailing list archive π (yes, the receipts are public).
you can report bugs either via github at:
https://github.com/tonycoz/imager/issues
or at:
https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Imager
or by sending an email to:
bug-Imager@rt.cpan.org
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 π (like, the bug report is only as iconic as the info you give it)
π CONTRIBUTING TO IMAGER π
π¬ Feedback
I like feedback.
you can send email to the maintainer below.
if you send me a bug report via email, it will be copied to Request Tracker.
π§ Patches
I accept patches, preferably against the master branch in git. please include an explanation of the reason for why the patch is needed or useful.
your patch should include regression tests where possible, otherwise it will be delayed until I get a chance to write them. lowkey the tests are the vibe check, ngl.
to browse Imager's git repository:
https://github.com/tonycoz/imager.git
to clone:
git clone git://github.com/tonycoz/imager.git
or you can create a fork as usual on github and submit a github pull request π
patches can either be submitted as a github pull request or by using git format-patch, for example, if you made your changes in a branch from master you might do:
git format-patch -k --stdout master >my-patch.txt
and then attach that to your bug report, either by adding it as an attachment in your email client, or by using the Request Tracker attachment mechanism.
π AUTHOR π
Tony Cook <tonyc@cpan.org> is the current maintainer for Imager.
Arnar M. Hrafnkelsson is the original author of Imager.
many others have contributed to Imager, please see the README for a complete list. (the whole squad fr fr π«Ά)
π LICENSE π
Imager is licensed under the same terms as perl itself.
a test font, generated by the Debian packaged Fontforge, FT2/fontfiles/MMOne.pfb, contains a Postscript operator definition copyrighted by Adobe. see adobe.txt in the source for license information. (legal girlies stay winning β¨)
β 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)
http://imager.perl.org/
Affix::Infix2Postfix(3), Parse::RecDescent(3)
other perl imaging modules include:
GD(3), Image::Magick(3), Graphics::Magick http://www.graphicsmagick.org/perl.html(3), Prima::Image, IPA.
for manipulating image metadata see Image::ExifTool.
if you're trying to use Imager for array processing, you should probably using PDL.
and that's the whole page, bestie!! this lil' beauty came from perl v5.42.3, dated 2026-08-19, and it's Imager(3pm) π
β¨ go forth and make iconic images π¦ππ
π¦ where this page comes from
- ubuntu stonking: libimager-perl 1.035+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms