Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
 I'm trying to write a module which turns images into data. 

I would have all my methods receive input in the form of raw data (refs), say 32bit. You do not need any of Magick's or GD's functionality (drawing boxes, writing text onto image etc.) so why have your methods demand Magick or GD object as input? As a convenience to the API user, you could supply a static method to convert a Magick or GD object into the raw data (refs) type your methods require (something like the factory methods some fellow monk mentioned).

But then, if the user already converted their image into 32bit raw data for input to your module's methods, you have little more to do than saving it into a file. Unless your aim is to provide data transformation/validation as well. If that's what you are after then ask for input in a common format, e.g. 32bit pixel data and start your module on this assumption. Much more productive than having to deal with Magick's or GD's internal formats. The biggest disadvantage is that getting a *reference* to image data from those objects may not be possible and your user may have to duplicate data ...

bw, bliako, (swimming) under Poseidon's temple

In reply to Re: Best practice for a module which can use one of multiple image modules by bliako
in thread Best practice for a module which can use one of multiple image modules by Cody Fendant

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (4)
    As of 2019-11-16 02:26 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (85 votes). Check out past polls.