The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Image::Base::Magick -- draw images using Image Magick

SYNOPSIS

 use Image::Base::Magick;
 my $image = Image::Base::Magick->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

Image::Base::Magick is a subclass of Image::Base,

    Image::Base
      Image::Base::Magick

DESCRIPTION

Image::Base::Magick extends Image::Base to create or update image files using Image::Magick.

The native ImageMagick drawing has hugely more features, but this module is an easy way to point Image::Base style code at an ImageMagick canvas and use the numerous file formats ImageMagick can read and write.

Colour names are anything recognised by ImageMagick,

    http://imagemagick.org/www/color.html
    file:///usr/share/doc/imagemagick/www/color.html

The names include 1, 2 and 4-digit hex "#RGB", "#RRGGBB", "#RRRRGGGGBBBB", other colour models, a table of names roughly per X11, and a file config/colors.xml of extras (under /usr/share/ImageMagick-6.6.0/ or whatever version number).

Anti-Aliasing

By default ImageMagick uses "anti-aliasing" to blur the edges of lines and circles drawn. This is unlike the other Image::Base modules but currently it's not changed or overridden in the methods here. Perhaps that will change, or perhaps only for canvases created by new() (as opposed to supplied in a -imagemagick parameter). You can turn it off explicitly with

    my $m = $image->get('-imagemagick');
    $m->Set (antialias => 0);

FUNCTIONS

$image = Image::Base::Magick->new (key=>value,...)

Create and return a new image object. A new image can be started with -width and -height,

    my $image = Image::Base::Magick->new (-width => 200,
                                          -height => 100);

Or an existing file can be read,

    my $image = Image::Base::Magick->new
                   (-file => '/some/filename.png');

Or an Image::Magick object can be given,

    $image = Image::Base::Magick->new (-imagemagick => $mobj);

ATTRIBUTES

-width (integer)
-height (integer)

Setting these changes the size of the image.

In the current code a Resize() is done which means the existing image is stretched, but don't depend on that. It might make more sense to crop when shrinking and pad with black when extending.

-imagemagick

The underlying Image::Magick object.

-file (string, default undef)

The filename for load or save, or passed to new to load a file.

The filename is used literally, it doesn't have ImageMagick's "%d" scheme for sets of numbered files. The code here is only geared towards a single image in a canvas, and a literal filename is the same as other Image::Base modules.

-file_format (string or undef)

The file format as a string like "PNG" or "JPEG", or undef if unknown or never set.

After load(), -file_format is the format read. Setting -file_format can change the format for a subsequent save(), or set the format for a newly created image.

This is the magick attribute of the ImageMagick object. Be careful of "X" format, which

    http://imagemagick.org/www/formats.html
    file:///usr/share/doc/imagemagick/www/formats.html

Some of the choices are pseudo-formats, for example saving as "X" displays a preview window in X windows, or "PRINT" writes to the printer.

-zlib_compression (integer 0-9 or -1, default undef)

The amount of data compression to apply when saving. The value is Zlib style 0 for no compression up to 9 for maximum effort. -1 means Zlib's default, usually 6. undef or never set means ImageMagick's default, which is 7. This attribute becomes the ImageMagick "quality" parameter for saving PNG.

For reference, ImageMagick (as of version 6.6) doesn't write a cursor "hotspot" in XPM format, so there's no -hotx and -hoty options.

SEE ALSO

Image::Base, Image::Magick

Image::Base::GD, Image::Base::PNGwriter, Image::Base::Imager, Image::Base::Gtk2::Gdk::Pixbuf, Image::Base::Prima::Image, Image::Xbm, Image::Xpm, Image::Pbm

Prima::Image::Magick

HOME PAGE

http://user42.tuxfamily.org/image-base-magick/index.html

LICENSE

Image-Base-Magick is Copyright 2010, 2011 Kevin Ryde

Image-Base-Magick 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-Magick 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-Magick. If not, see <http://www.gnu.org/licenses/>.