Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Output is SVG source on Windows #12

Open
bryanburgers opened this issue Feb 28, 2014 · 4 comments
Open

Output is SVG source on Windows #12

bryanburgers opened this issue Feb 28, 2014 · 4 comments

Comments

@bryanburgers
Copy link

On Windows 7, the output is not the image, but an image of the source code for the SVG.

This only occurs if the SVG does not have an XML declaration. If I add <?xml version="1.0"?> to the document, it will work correctly.

division-corner

SVG Source:

<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"><path d="M1 0l24 24v-24z" fill="#fff"/><path d="M0 1l24 24h1v-5l-20-20h-5z" fill="#cc092f"/></svg>
@deantpt
Copy link

deantpt commented Apr 1, 2015

Has anyone found a workaround for this?

@smyli323
Copy link

Not sure if you are using 'svgmin' but I found 'svgmin' was messing it up for me. If i move it after 'svg2png' in my Gruntfile.js in grunt.registerTask(), then it generates the png properly, didn't need the xml declaration either.

@jtbr
Copy link

jtbr commented Sep 1, 2015

Another workaround for you need to run svgmin before svg2png (as if you are using grunticon), you can simply disable the removal of the xml declaration in svgmin:

svgmin: {
    dist: {
        options: {
            plugins: [
                { removeXMLProcInst: false } // don't remove xml processing instructions (doing so causes svg2png to fail at least on win 7)
            ]
        },
        files: [{
            expand: true,   cwd: 'sourcedir', src: ['*.svg'], dest: 'destdir'
        }]
    }
}

Of course, ideally, svg2min could support files without the xml declaration.

@jonnystening
Copy link

Worth mentioning... the latest version of Illustrator (I'm on v19.2.0) has a new 'Export... SVG' dialog which seems to automatically strip the declaration.

grunt-svg2png still needs this declaration in order to output a rasterized SVG graphic (rather than rasterized lines of XML code).

Grrrrr.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants