Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by dwm042 (Priest)
on Jul 28, 2011 at 03:59 UTC ( [id://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.

David.

Replies are listed 'Best First'.
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2025-06-21 15:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.