Image::Imlib2 is a Perl interface to the Imlib2 image library.
# create a new image
my $image = Image::Imlib2->new(200, 200);
# or load an image
$image = Image::Imlib2->load("foo.png");
# Enable the alpha channel support
# set a colour (rgba, so this is transparent orange)
$image->set_color(255, 127, 0, 127);
# draw a rectangle
$image->draw_rectangle(50, 50, 50, 50);
# draw a filled rectangle
$image->fill_rectangle(150, 50, 50, 50);
# draw a line
$image->draw_line(0, 0, 200, 50);
# set quality before saving
# save out
# create a polygon
my $poly = Image::Imlib2::Polygon->new();
# add some points
# fill the polygon
# draw it closed on image
# create a color range
my $cr = Image::Imlib2::ColorRange->new();
# add a color
my ($distance, $red, $green, $blue, $alpha) = (15, 200, 100, 50, 20);
$cr->add_color($distance, $red, $green, $blue, $alpha);
# draw it
my($x, $y, $width, $height, $angle) = (20, 30, 200, 200, 1);
$image->fill_color_range_rectangle($cr, $x, $y,
$width, $height, $angle);
Image::Imlib2 is a Perl port of Imlib2, a graphics library that does image file loading and saving as well as manipulation, arbitrary polygon support, etc. It does ALL of these operations FAST. It allows you to create colour images using a large number of graphics primitives, and output the images in a range of formats.
Image::Imlib2::Polygon and Image::Imlib2::ColorRange are described following Image::Imlib2 but may be referenced before their description.
Note that this is an early version of my attempt at a Perl interface to Imlib2. Currently, the API is just to test things out. Not everything is supported, but a great deal of functionality already exists. If you think the API can be tweaked to be a bit more intuitive, drop me a line!
Note that a development version of Imlib2 must be installed before installing this module.