Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Are objects derived from Graphics::Magick CPAN-okay?

by dwm042 (Priest)
on Jul 28, 2011 at 03:59 UTC ( #917176=perlquestion: print w/ replies, xml ) Need Help??
dwm042 has asked for the wisdom of the Perl Monks concerning the following question:

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.


Comment on Are objects derived from Graphics::Magick CPAN-okay?
Select or Download Code
Re: Are objects derived from Graphics::Magick CPAN-okay?
by Tanktalus (Canon) on Jul 28, 2011 at 04:06 UTC

    Can CPAN code be based on Graphics::Magick? Why not? It works for you, you want to share it, I don't see any issue. :-)

    Should such code look for either module and switch? If it works, and you want to do so, be my guest. I don't see that as a prerequisite.

    Test graphics modules? I'm not sure. Have you looked at, for example, unit tests for GD? Or any other graphic-output module? That's where I'd start looking.

Re: Are objects derived from Graphics::Magick CPAN-okay?
by Khen1950fx (Canon) on Jul 28, 2011 at 04:45 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://917176]
Approved by Tanktalus
Front-paged by Tanktalus
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-08-02 07:14 GMT
Find Nodes?
    Voting Booth?

    Who would be the most fun to work for?

    Results (55 votes), past polls