0

I am in a project,that convert svg to png in the server side----node.js server.So I use imagemagick and the the server install imagemagick 6.7.7 also install the libsvg2-bin.Everything works well but the text encoding problem.The server use UTF-8 but failed to convert.

require("fs").writeFile(target_path_svg, svg, [], function(err) {
    if (err) {
        res.send(err);
        return;
    } else {
        im.convert([target_path_svg, 'png:-'], function(err, stdout) {
            if (err) {
                throw err
                res.send("error");
            }
            fs.writeFileSync(target_path, stdout, 'binary');
            res.send("ok");
            return;
        });
        return;
    }
});

anyone help?

1 Answer 1

0

As a workaround, pass target_path as the second parameter in the array in the call to im.convert() (instead of png:-). It will directly write the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.