Potrace is a program (and a library) by Peter Salinger for Transforming bitmaps into vector graphics, distributed under the GNU General Public Licence. This distribution aims at binding the library from Perl for your fun and convenience (guarantees not included!).
# Step by step use Graphics::Potrace qw< raster >; my $raster = raster(' .......................... .......XXXXXXXXXXXXXXX.... ..XXXXXXXX.......XXXXXXX.. ....XXXXX.........XXXXXX.. ......XXXXXXXXXXXXXXX..... ...XXXXXX........XXXXXXX.. ...XXXXXX........XXXXXXX.. ....XXXXXXXXXXXXXXXXXX.... .......................... '); my $vector = $raster->trace(); $vector->export(Svg => file => 'example.svg'); $vector->export(Svg => file => \my $svg_dump); $vector->export(Svg => fh => \*STDOUT); # There is a simpler way to get a dump in a scalar my $eps = $vector->render('Eps'); # All in one facility use Graphics::Potrace qw< trace >; trace( raster => ' .......................... .......XXXXXXXXXXXXXXX.... ..XXXXXXXX.......XXXXXXX.. ....XXXXX.........XXXXXX.. ......XXXXXXXXXXXXXXX..... ...XXXXXX........XXXXXXX.. ...XXXXXX........XXXXXXX.. ....XXXXXXXXXXXXXXXXXX.... .......................... ', vectorial => [ Svg => file => 'example.svg' ], ); # There is a whole lot of DWIMmery in both raster() and trace(). # Stick to Graphics::Potrace::Raster for finer control use Graphics::Potrace::Raster; my $raster = Graphics::Potrace::Raster->load( Ascii => text => ' .......................... .......XXXXXXXXXXXXXXX.... ..XXXXXXXX.......XXXXXXX.. ....XXXXX.........XXXXXX.. ......XXXXXXXXXXXXXXX..... ...XXXXXX........XXXXXXX.. ...XXXXXX........XXXXXXX.. ....XXXXXXXXXXXXXXXXXX.... .......................... ', ); # you know what to do with $raster - see above!
Find it on CPAN - Graphics::Potrace - and on Github - Graphics-Potrace. You can also clone the project with Git by running:
$ git clone git://github.com/polettix/Graphics-Potrace