Author image Kevin Ryde
and 1 contributors


Image::Base::SVGout -- SVG image file output


 use Image::Base::SVGout;
 my $image = Image::Base::SVGout->new (-width => 100,
                                                       -height => 100);
 $image->set (-file => '/some/filename.svg');
 $image->rectangle (0,0, 99,99, 'red');
 $image->xy (20,20, '#FF00FF');
 $image->line (50,50, 70,70, 'white');
 $image->line (50,50, 70,70, 'green');


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



Image::Base::SVGout extends Image::Base to write SVG format image files progressively.

This is an unusual Image::Base module in that it writes to its -file during drawing, rather than holding an image in memory. This means drawing operations are just prints of SVG elements to the file, but also means a -file must be specified before drawing. The final save() just writes a closing </svg> to the file.

The Image::Base functions are pixel oriented so aren't really the sort of thing SVG is meant for, but this module at least makes it possible to get some SVG out of Image::Base style drawing code. SVG has many more features than can be accessed with the functions here, and it's just XML text so often isn't hard to spit out directly instead too.

See Image::Base::SVG for similar SVG output but going to an object.


See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.

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

Create and return a new SVGout image object.

    $image = Image::Base::SVGout->new (-width => 200, -height => 100);
$newimage = $image->new (key=>value,...)

Clone $image and apply the given settings. This can only be done before drawing has begun.

$colour = $image->xy ($x, $y)

Get an individual pixel. The return is always undef since there's no support for picking out elements etc from the drawn SVG.

$image->load ()
$image->load ($filename)

Loading is not possible with this module.

$image->save ()
$image->save ($filename)

Save the image to an SVG file, either the current -file option, or set that option to $filename and save to there.


-width (integer)
-height (integer)

Set the SVG canvas size in pixels. These must be set before the first drawing operation, and cannot be changed after the first drawing operation (because they're printed in the initial SVG header).


Image::Base, Image::Base::SVG



Image-Base-Other is Copyright 2010, 2011, 2012 Kevin Ryde

Image-Base-Other 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-Other 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-Other. If not, see <>.