Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Alternative to $image->copy() in GD module

by Ezhil4663 (Novice)
on Jul 06, 2016 at 13:17 UTC ( [id://1167300]=perlquestion: print w/replies, xml ) Need Help??

Ezhil4663 has asked for the wisdom of the Perl Monks concerning the following question:

I am looking for an alternative to the function $image->copy in the GD module. My current line of code is $image->copy($subimage, 10, 10, 0, 0, $subx, $suby); I am not able to use this function in the SVG::GD module. So I am looking for an alternative program that does the same job.
  • Comment on Alternative to $image->copy() in GD module

Replies are listed 'Best First'.
Re: Alternative to $image->copy() in GD module
by BrowserUk (Patriarch) on Jul 06, 2016 at 22:56 UTC

    What are you wanting from this copy command? Ie:

    1. A bitmap containing a subsection of the plotted SVG drawing.

      This is trivial to do.

    2. Another SVG that represents only that part of the original within the bounds specified.

      This, by my research, is impossible.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Alternative to $image->copy() in GD module
by Marshall (Canon) on Jul 06, 2016 at 17:09 UTC
    I spent some time looking for a direct answer to your question with no results. However, maybe a slightly different question might yield some result?

    You are apparently happy with the functionality of SVG::GD. What is behind this: "I am not able to use this function in the SVG::GD module"? Maybe there is some issue like module installation, etc. that can be addressed? Also, let's say somebody comes up with another program that does the same thing...what's to say that you can or can't use that one either? What is the limiting factor that is driving the original question?

      SVG::GD doesn't provide a copy method. It overrides some of the GD::Font and GD::Image methods by aliasing *GD::Image:: to *SVG::GD::Image:: and *GD::Font:: to *SVG::GD::Font::, but there's no SVG::GD::Image::copy so you get Can't locate object method "copy" via package "SVG::GD::Image". Therefore, I am looking for alternative methods.

        I assume that you already evaluated and rejected the similarly-named GD::SVG, which does implement the copy method (but not clone, copyMerged, etc.). (I've never used either, so I don't know the merits of one over the other.)

        You might want to try to roll your own sub SVG::GD::Image::copy { ... }: create the initial image with SVG::GD::Image::new(); use Data::Dumper (or similar) to get the details of the SVG::GD::Image object and find all the attributes/data that are important to you, and copy those attributes from the original to the new. I think you can just define it in your own code using the fully-qualified package:: name, but if not, put it in your installed copy of SVG/GD.pm (assuming you have write privileges).

        Once you've got it working, you can send it to the maint of SVG::GD as a feature request; having written the code already, it's much more likely to make it in. :-)

Re: Alternative to $image->copy() in GD module (CROSSPOSTED)
by LanX (Saint) on Jul 30, 2016 at 10:09 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-18 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found