This all began as a way to draw diagrams for American football (I have a blog mixing football, curve fits using
PDL, stats using
PDL::Stats, graphs using
Chart::Clicker, and other bits of Perl, called "Code and Football"), and originally I was mostly using Windows batch and command line Image Magick.
A bash equivalent might be something like this..
#! /bin/bash
convert -size 100x100 -stroke SeaGreen -fill palegreen -strokewidth 2
+\
xc:white -draw 'translate 50,50 circle 0,0,25,0' /share/circle_script.
+jpg
After a while I got interested in doing the same things in Perl, because typing
'convert blah blah' all the time was getting old, and code reuse was becoming more and more a factor.
I started rewriting things into PerlMagick and lo and behold, things started breaking, such as this simple way to draw a circle using translate. The code below demonstrates my issue (i.e. translate fails).
#! /usr/bin/perl
use warnings;
use strict;
use Image::Magick;
my $p = Image::Magick->new;
$p->Set( size => '100x100');
$p->Read("xc:white");
$p->Draw( primitive => 'circle' ,translate => "50,50",
stroke => 'SeaGreen', strokewidth => 2, fill => 'palegreen',
points => '0,0,25,0' );
$p->Write("/share/circle_perl.jpg");
I have this problem with the default IM packages in both Ubuntu 10.04 and Ubuntu 11.04. But if I switch to Graphics::Magick, it
just works.
Thing is, I don't see Graphics::Magick in CPAN and after having authored one whole CPAN module, I'm growing a little fond of that way of "publishing" code. But some questions, I think, are worth asking at this point, before pushing too far up the possible CPAN path.
- Can CPAN code be based on Graphics::Magick?
- Should such code look for either module, and switch?
- How do you test a proposed graphics module, whose output is visual, with something like Test::More?
Any comments, hints, ideas appreciated.
David.