Image::Base::Imlib2 -- draw images using Imlib2
use Image::Base::Imlib2; my $image = Image::Base::Imlib2->new (-width => 100, -height => 100); $image->rectangle (0,0, 99,99, '#FFF'); # white $image->xy (20,20, '#000'); # black $image->line (50,50, 70,70, '#FF00FF'); $image->line (50,50, 70,70, '#0000AAAA9999'); $image->save ('/some/filename.png');
Image::Base::Imlib2 is a subclass of Image::Base,
Image::Base::Imlib2
Image::Base
Image::Base Image::Base::Imlib2
Image::Base::Imlib2 extends Image::Base to create or update image files using the Image::Imlib2 module.
Image::Imlib2
The following file formats are available, as of Imlib2 1.4.4, provided Imlib2 was built with necessary supporting libraries (such as libpng).
libpng
PNG, JPEG, TIFF, PNM, BMP GIF read-only XPM read-only TGA Targa LBM Amiga Paint, read-only ARGB raw something format (?)
There's no named colours as such, only hex and a special "None" for transparent
#RGB #RRGGBB #RRRGGGBBB #RRRRGGGGBBBB None transparent
When an XPM file is loaded the /usr/share/X11/rgb.txt file (possibly in other directories) is consulted for named colours in the XPM, but that's not made available to drawing operations as such.
See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.
$image = Image::Base::Imlib2->new (key=>value,...)
Create and return a new image object. A new image can be started with -width and -height,
-width
-height
$image = Image::Base::Imlib2->new (-width => 200, -height => 100);
Or an existing file can be read,
$image = Image::Base::Imlib2->new (-file => '/some/filename.png');
Or an Image::Imlib2 object can be given,
my $imlibobj = Image::Imlib2->new (20, 10); $image = Image::Base::Imlib2->new (-imlib => $imlibobj);
$new_image = $image->new (key=>value,...)
Create and return a copy of $image. The Imlib2 object within $image is cloned per $imlib->clone(). Optional key/value parameters are applied to the new image as per $image->set().
$image
$imlib->clone()
$image->set()
# copy image, new quality level my $new_image = $image->new (-quality_percent => 100);
$image->load ()
$image->load ($filename)
Read the -file, or set -file to $filename and then read.
-file
$filename
This creates and sets a new underlying -imlib object because it's not possible to read into an existing object, only create a new one for the load.
-imlib
$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 attribute (see below).
-file_format
The size of the underlying Image::Imlib2 is set when created and can't be changed after that. (Is that right?)
The underlying Image::Imlib2 object.
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 subsequent save().
load()
save()
This is applied with $imlib->set_file_format() and is currently write-only.
$imlib->set_file_format()
-quality_percent
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.
For PNG, Imlib2 turns this into a Zlib compression level, but the intention is to have a separate -zlib_compression attribute (if Image::Imlib2 offers the necessary imlib_image_attach_data_value()).
-zlib_compression
imlib_image_attach_data_value()
Imlib2 interprets filenames like "name:foo.bar" with a colon as meaning a sub-part of some 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 the interests of consistency and being certain what file is opened, but it's not clear if that's possible.
For reference, in the current implementation ellipse() is done with the Image::Base superclass code, since the native ellipse drawing in Imlib2 1.4.4 seems a bit dubious, seeming to go outside the requested size. In any case the native ellipse parameters are integers for an x,y centre and a,b semi-radii which would mean it could only be for odd sizes anyway, ie. $x2-$x1+1 and $y2-$y1+1 both odd numbers.
ellipse()
$x2-$x1+1
$y2-$y1+1
Image::Base, Image::Imlib2
Imlib2 documentation
http://docs.enlightenment.org/api/imlib2/html/index.html file://usr/share/doc/libimlib2-dev/html/index.html
http://user42.tuxfamily.org/image-base-imlib2/index.html
Image-Base-Imlib2 is Copyright 2011 Kevin Ryde
Image-Base-Imlib2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Image-Base-Imlib2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Image-Base-Imlib2. If not, see <http://www.gnu.org/licenses/>.
To install Image::Base::Imlib2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Image::Base::Imlib2
CPAN shell
perl -MCPAN -e shell install Image::Base::Imlib2
For more information on module installation, please visit the detailed CPAN module installation guide.