NAME
App::MathImage::Image::Base::Imlib2 -- draw images using Imlib2
SYNOPSIS
use App::MathImage::Image::Base::Imlib2;
my $image = App::MathImage::Image::Base::Imlib2->new (-width => 100,
-height => 100);
$image->rectangle (0,0, 99,99, 'white');
$image->xy (20,20, 'black');
$image->line (50,50, 70,70, '#FF00FF');
$image->line (50,50, 70,70, '#0000AAAA9999');
$image->save ('/some/filename.png');
CLASS HIERARCHY
App::MathImage::Image::Base::Imlib2
is a subclass of Image::Base
,
Image::Base
App::MathImage::Image::Base::Imlib2
DESCRIPTION
App::MathImage::Image::Base::Imlib2
extends Image::Base
to create or update image files using the Image::Imlib2
module.
As of Imlib2 1.4.4 the following file formats are available, provided for some of them that Imlib2 was built with supporting libraries (such as libpng
).
PNG, JPEG, TIFF, PNM, BMP
GIF read-only
XPM read-only
TGA Targa
LBM Amiga Paint, read-only
ARGB raw format from Imlib (?)
Colour Names
There's no named colours as such, only hex and a special "None" for transparent
#RGB
#RRGGBB
#RRRGGGBBB
#RRRRGGGGBBBB
None transparent
When loading XPM files /usr/share/X11/rgb.txt or similar is consulted for named colours in the file, but that's not made available to later drawing operations.
FUNCTIONS
$image = App::MathImage::Image::Base::Imlib2->new (key=>value,...)
-
Create and return a new image object. A new image can be started with
-width
and-height
,$image = App::MathImage::Image::Base::Imlib2->new (-width => 200, -height => 100);
Or an existing file can be read,
$image = App::MathImage::Image::Base::Imlib2->new (-file => '/some/filename.png');
Or an
Image::Imlib2
object can be given,my $imlibobj = Image::Imlib2->new (20, 10); $image = App::MathImage::Image::Base::Imlib2->new (-imlib => $imlibobj);
$new_image = $image->new (key=>value,...)
-
Create and return a copy of
$image
. The Imlib object within$image
is cloned per$imlib->clone()
. Optional key/value parameters are applied to the new image as perset()
.# copy image, new compression level my $new_image = $image->new (-zlib_compression => 9);
$image->load
$image->load ($filename)
-
Read the
-file
, or set-file
to$filename
and then read.This creates and sets a new underlying
-imlib
because it's not possible to read into an existing Imlib2 object, only create a new one from the load. $image->save ()
$image->save ($filename)
-
Save to
-file
, or with a$filename
argument set-file
then save to that.The file format is taken from the
-file_format
(see below) if that was set by aload
or explicitset
, otherwise Imlib2 follows the filename extension. In both cases if format or extension is unrecognised thensave()
croaks.
ATTRIBUTES
-width
(integer, create-only)-height
(integer, create-only)-
The size of the underlying
Image::Imlib2
is set when created and can't be changed after that. (Is that right?) -imlib
-
The underlying
Image::Imlib2
object. -file_format
(string orundef
, write-only)-
The file format as a string like "png" or "jpeg".
After
load()
the-file_format
is the format read. Setting-file_format
can change the format for a subsequentsave()
.This is applied with
$imlib->set_file_format()
and is currently write-only. -quality_percent
(0 to 100, write-only)-
The image quality for saving to JPEG format. JPEG compresses by reducing colours and resolution in ways that are not too noticeable to the human eye. 100 means full quality, no such reductions.
BUGS
Imlib2 interprets filenames with a colon like "name:foo.bar" as meaning a sub-part of certain file formats. If the full "name:foo.bar" exists and is a ordinary file (not a char special) then it loads that, otherwise it tries "name" alone. This is unlike other Image::Base
modules and the intention would be to avoid it in load()
and save()
in the interests of consistency, if possible.
In the current implementation ellipse()
is done with the Image::Base
code, since in Imlib2 1.4.4 the native ellipse drawing seems a bit dubious, going outside the requested size. In any case they would only be applicable for odd sides, meaning $x2-$x1+1
and $y2-$y1+1
both odd numbers, since they take an x,y centre and a,b semi-radii must be integers.
SEE ALSO
file://usr/share/doc/libimlib2-dev/html/index.html