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::PNGwriter -- draw PNG format images

SYNOPSIS

 use Image::Base::PNGwriter;
 my $image = Image::Base::PNGwriter->new (-width => 100,
                                          -height => 100);
 $image->line (0,0, 99,99, '#FF00FF');
 $image->rectangle (10,10, 20,15, 'white');
 $image->ellipse (30,30, 90,90, '#AAAA3333DDDD');
 $image->save ('/some/filename.png');

CLASS HIERARCHY

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

    Image::Base
      Image::Base::PNGwriter

DESCRIPTION

Image::Base::PNGwriter extends Image::Base to create or update PNG format image files using the Image::PNGwriter module and pngwriter library.

The native PNGwriter has more features, but this module is an easy way to point Image::Base style code at a PNGwriter and is a good way to get PNG out of some Image::Base code.

There's no colour name database as yet, only "black", "white" and hex "#RRGGBB" or "#RRRRGGGGBBBB".

X,Y coordinates are the usual Image::Base style 0,0 at the top-left corner. The underlying pngwriter library is 1,1 as the bottom-left but Image::Base::PNGwriter converts.

FUNCTIONS

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

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

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

Or an existing file can be read,

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

Or an Image::PNGwriter object can be given,

    $image = Image::Base::PNGwriter->new (-pngwriter => $pwobj);
$image->ellipse ($x1,$y1, $x2,$y2, $colour)

Draw an ellipse within the rectangle bounded by $x1,$y1 and $x2,$y2.

In the current implementation circles with an odd diameter (when $x2-$x1+1 is equal to $y2-$y1+1 and is an odd number) are drawn with PNGwriter and the rest go to Image::Base. This is a bit inconsistent but uses the features of pngwriter as far as possible and its drawing should be faster.

ATTRIBUTES

The following attributes can be get and set.

-file (string filename)

The file to load in a new, and the default filename for subsequent save or load.

-width (integer)
-height (integer)

Setting these changes the size of the image, but also clears it to all black. The image must be at least 1x1 pixels.

-zlib_compression (integer 0-9 or -1)

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 level.

-pngwriter (Image::PNGwriter object)

The underlying Image::PNGwriter object in use.

Because filename and compression level can't be read out of a pngwriter object, if you set -pngwriter then a get of the -file or -zlib_compression will return undef and there's no default filename for load. A save will use the filename and compression in the object though. Perhaps this will improve in the future.

SEE ALSO

Image::Base, Image::PNGwriter, Image::Base::GD

HOME PAGE

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

LICENSE

Image-Base-PNGwriter is Copyright 2010 Kevin Ryde

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