Security Advisories (6)
CVE-2016-1238 (2016-08-02)

Imager would search the default current directory entry in @INC when searching for file format support modules.

CPANSA-Imager-2014-01 (2014-01-03)

When drawing on an image with an alpha channel where the source minimum is greater than zero, Imager would read from beyond the end of a malloc() allocated buffer. In rare circumstances this could lead to some of the source image not being written to the target image, or possibly to a segmentation fault.

CVE-2024-53901 (2024-11-17)

"invalid next size" backtrace on use of trim on certain images

CVE-2026-8669 (2026-05-15)

Imager versions through 1.030 for Perl allow a heap out of bounds (OOB) write on crafted multi-frame GIF files. Imager::File::GIF's i_readgif_multi_low allocates a single per-row buffer GifRow sized for the GIF's global screen width 'SWidth' and reuses it across every image in the file. The page-match branch validates Image.Width + Image.Left > SWidth before each DGifGetLine write, but the parallel skip-image branch at imgif.c:790-805 calls DGifGetLine(GifFile, GifRow, Width) with no such check.

CVE-2026-13705 (2026-07-06)

Imager versions before 1.032 for Perl have a heap out-of-bounds read in the bundled Imager::File::SGI reader via a 16-bit RLE literal run in read_rgb_16_rle. read_rgb_16_rle guards each literal run with if (count > data_left), but count is a pixel count while every 16-bit sample consumes two bytes. The copy loop reads inp[0] * 256 + inp[1] and advances two bytes per pixel, so a run with data_left / 2 < count <= data_left passes the guard yet consumes 2 * count bytes and reads past the end of the buffer. The 8-bit path is unaffected because there one pixel is one byte. Reading a crafted SGI image through Imager->read triggers the over-read before the parser rejects the malformed image, which can crash the process.

CVE-2026-14454 (2026-07-08)

Imager versions before 1.033 for Perl treat unsigned EXIF IFD entry counts as signed. Imager mishandled large EXIF IFD entry count values, treating them as negative numbers. This could lead to an attempt to allocate a block nearly the size of the address space, which fails and kills the process. An attacker could craft an image with EXIF data that terminates a worker process.

NAME

Imager::Matrix2d - simple wrapper for matrix construction

SYNOPSIS

use Imager::Matrix2d;
$m1 = Imager::Matrix2d->identity;
$m2 = Imager::Matrix2d->rotate(radians=>$angle, x=>$cx, y=>$cy);
$m3 = Imager::Matrix2d->translate(x=>$dx, y=>$dy);
$m4 = Imager::Matrix2d->shear(x=>$sx, y=>$sy);
$m5 = Imager::Matrix2d->reflect(axis=>$axis);
$m6 = Imager::Matrix2d->scale(x=>$xratio, y=>$yratio);
$m8 = Imager::Matric2d->matrix($v11, $v12, $v13,
                               $v21, $v22, $v23,
                               $v31, $v32, $v33);
$m6 = $m1 * $m2;
$m7 = $m1 + $m2;
use Imager::Matrix2d qw(:handy);
# various m2d_* functions imported 
# where m2d_(.*) calls Imager::Matrix2d->$1()

DESCRIPTION

This class provides a simple wrapper around a reference to an array of 9 coefficients, treated as a matrix:

[ 0, 1, 2,
  3, 4, 5,
  6, 7, 8 ]

Most of the methods in this class are constructors. The others are overloaded operators.

Note that since Imager represents images with y increasing from top to bottom, rotation angles are clockwise, rather than counter-clockwise.

identity()

Returns the identity matrix.

rotate(radians=>$angle)
rotate(degrees=>$angle)

Creates a matrix that rotates around the origin, or around the point (x,y) if the 'x' and 'y' parameters are provided.

translate(x=>$dx, y=>$dy)
translate(x=>$dx)
translate(y=>$dy)

Translates by the specify amounts.

shear(x=>$sx, y=>$sy)
shear(x=>$sx)
shear(y=>$sy)

Shear by the given amounts.

reflect(axis=>$axis)

Reflect around the given axis, either 'x' or 'y'.

reflect(radians=>$angle)
reflect(degrees=>$angle)

Reflect around a line drawn at the given angle from the origin.

scale(x=>$xratio, y=>$yratio)

Scales at the given ratios.

You can also specify a center for the scaling with the cx and cy parameters.

matrix($v11, $v12, $v13, $v21, $v22, $v23, $v31, $v32, $v33)

Create a matrix with custom coefficients.

_mult()

Implements the overloaded '*' operator. Internal use.

Currently both the left and right-hand sides of the operator must be an Imager::Matrix2d.

_add()

Implements the overloaded binary '+' operator.

Currently both the left and right sides of the operator must be Imager::Matrix2d objects.

_string()

Implements the overloaded stringification operator.

This returns a string containing 3 lines of text with no terminating newline.

I tried to make it fairly nicely formatted. You might disagree :)

_eq

Implement the overloaded equality operator.

Provided for older perls that don't handle magic auto generation of eq from "".

The following functions are shortcuts to the various constructors.

These are not methods.

You can import these methods with:

use Imager::Matrix2d ':handy';
m2d_identity
m2d_rotate()
m2d_translate()
m2d_shear()
m2d_reflect()
m2d_scale()

AUTHOR

Tony Cook <tony@develop-help.com>

BUGS

Needs a way to invert a matrix.

SEE ALSO

Imager(3), Imager::Font(3)

http://imager.perl.org/