Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Best practice for a module which can use one of multiple image modules

by bliako (Vicar)
on Aug 19, 2019 at 22:04 UTC ( #11104703=note: print w/replies, xml ) Need Help??


in reply to Best practice for a module which can use one of multiple image modules

 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

  • Comment on Re: Best practice for a module which can use one of multiple image modules

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104703]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2019-12-08 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (162 votes). Check out past polls.

    Notices?