Don't know where to start on helping.
I want to take an SVG with a transparent background and save it as a PNG with the same transparent background.
If I use the following command line everything works as expected:
gm convert -background none icon.svg icon.png
But, if I use the following CS line, the transparent property is lost (same thing in JS):
gm('icon.svg').background('none').write 'icon.png', (err) -> console.log err if err
No error is returned so it looks like the background command/property is there, but it doesn't do what it is supposed to. It ends up with a plain white background.
use DEBUG=gm and see what command actually gets executed
Hi Jonathan. This may be a dumb question but where do I put this DEBUG=gm assertion? Before calling the REPL?
in a test script. https://github.com/visionmedia/debug very useful for debugging :D
Didn't know this one. I'm checking it. Thx.
Here's the command line generated:
gm "convert" "icon.svg" "-background" "none" "icon.png"
OK, I get it. The SVG image is loaded by GM before the background is set. Thus, the SVG is rendered on a white background and the real background directive has no impact.
Doing this, works fine:
gm "convert" "-background" "none" "icon.svg" "icon.png"
Doing that, fails (the gm module's way):
In essence, the background directive should be called before the SVG is loaded. It's an in directive.
Do you have any clue how I should proceed?
okay looks like "background" is a setting, so should be moved to the front: http://www.imagemagick.org/script/command-line-processing.php
if you want to make a PR, it's a matter of switching the function from .out to .in: https://github.com/aheckmann/gm/blob/master/lib/args.js#L1046 + a test
otherwise, i'll get to it eventually
I'm currently at work but I'm eager on contributing back to this project. If you allow me, I would be glad to make the PR and its tests. Thanks to your hint, I should be able to do it on my own.
Jonathan, I've performed the updates. It works nicely and the tests have been updated accordingly. I've done my modification on the master branch. How do I push them as I'm not among the declared contributors?
Fix issue #245: background('none') leads to a white background