Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Image Conversion: SVG to PNG

by Corion (Patriarch)
on Apr 24, 2017 at 08:37 UTC ( [id://1188742]=note: print w/replies, xml ) Need Help??


in reply to Image Conversion: SVG to PNG

I don't use a module, but I also don't have hard-core conversion requirements.

I invoke Inkscape from the command line as

my $cmd = qq{"$inkscape" -D "--export-png=$tempfile" --export-text +-to-path --without-gui "$source"};

This is somewhat slow as I have to relaunch the Inkscape process often, but after I moved to make respectively Decision::Depends, that is only needed when the input SVGs actually changed.

If you're already battling with ImageMagick, using something else might be a way to keep more of your sanity.

Replies are listed 'Best First'.
Re^2: Image Conversion: SVG to PNG
by vrk (Chaplain) on Apr 24, 2017 at 10:26 UTC

    Inkscape has good quality output, so if you only need to generate the graphics at build or configuration time, this is a good solution. Unfortunately it doesn't quite scale up for interactive CGI use!

      Iirc inkscape.exe is just a py2exe python program -- shouldnt take much code to daemonize it 💩
Re^2: Image Conversion: SVG to PNG
by kcott (Archbishop) on Apr 25, 2017 at 09:52 UTC

    G'day Corion,

    I did, in fact, look at Inkscape only a few days ago. This was more out of curiousity than anything else, as I don't actually need a tool to generate the SVG. I was put off by some of the issues with Mac OS X: none insurmountable but sufficiently annoying (for me, at any rate) that I didn't investigate further. I wasn't aware of the command line and export facilities: thanks for pointing those out — maybe I'll take another look.

    Actually, curiousity grabbed me again. I did a little more investigating (in the middle of replying) and found the manpage. It would appear that the first command line from my OP:

    $ convert test.svg -resize 16x16 test016.png

    could be written, using Inkscape, as:

    $ inkscape -z -e test016.png -w 16 -h 16 test.svg

    That seems fairly painless. It's also completely untested as I haven't installed Inkscape. Having to "relaunch the Inkscape process often" is a concern.

    No, I'm not battling anything at this point. I'm really just at the requirements analysis stage and searching for the best tools. My sanity, at least for now, remains intact; but thankyou for your concern. :-)

    — Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-23 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found