-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for SVG as data URL missing #807
Comments
@FransBosuil please try out PR #811 |
@foysavas That PR did not work |
@ankurp Ah, you're using a data url as the |
Any plans to support this? |
Works by converting to a file buffer. |
Does this works with [email protected]? And how to convert the SVG-Data to file-buffer? |
Fixes Automattic#945 - support img.src = <url> Fixes Automattic#807 - support for non-base64 `data:` URIs Fixes Automattic#1079 - ditto Closes Automattic#564 - it works, probably didn't pass a string or buffer Makes all examples and the README use onload, onerror.
Fixes Automattic#945 - support img.src = <url> Fixes Automattic#807 - support for non-base64 `data:` URIs Fixes Automattic#1079 - ditto Closes Automattic#564 - it works, probably didn't pass a string or buffer Makes all examples and the README use onload, onerror.
Fixes Automattic#945 - support img.src = <url> Fixes Automattic#807 - support for non-base64 `data:` URIs Fixes Automattic#1079 - ditto Closes Automattic#564 - it works, probably didn't pass a string or buffer Makes all examples and the README use onload, onerror.
Fixes Automattic#945 - support img.src = <url> Fixes Automattic#807 - support for non-base64 `data:` URIs Fixes Automattic#1079 - ditto Closes Automattic#564 - it works, probably didn't pass a string or buffer Makes all examples and the README use onload, onerror.
Hello, can anyone give an example of how to make the following code work: var svgString = `
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="400" height="400" viewBox="0 0 100 100">
<rect x="0" y="0" width="100" height="100" fill="green"></rect>
<rect x="0" y="0" width="50" height="50" fill="blue"></rect>
</svg>
`.trim();
var svgData = 'data:image/svg+xml;charset=utf-8,' + svgString;
var svg = new Canvas.Image;
svg.onload = function() {
console.log("TODO create png from svg image");
}
svg.onerror = function(error) {
console.log("ERROR: " + error);
};
svg.src = svgData; |
@cpapidas I think that is correct, but you need the 2.x branch for it to work. Version 1.x has a bug where it assumes the |
@zbjornson the code example above doesn't work for me with node-canvas=2.0.0-alpha.13 and node v8.10.0; I get Is this still an outstanding issue? |
@zbjornson with node-canvas=2.0.1, I now get This is on linux, with |
@Hamms sorry, forgot that prebuilds don't have SVG Support yet (node-gfx/node-canvas-prebuilt#59). Can you try |
I'm using the library dom-to-image (in node.js) to convert some DIV content to an image. The library adds the DIV to an SVG foreign object, converts the SVG to a data URL and updates the src property of a canvas image. So far so good. However, the last step fails with the message
Error: error while reading from input stream
.From other issues, I found that the log message is thrown in Image.cc and that it comes from the variable CAIRO_STATUS_READ_ERROR. Looking at the behaviour of Image.cc, it looks like the above functionality is not supported. In the load methods (load/loadFromBuffer), there is only support for PNG, GIF and JPEG.
I understood that there was already support for SVG. Does this include the above functionality?
Test code
The text was updated successfully, but these errors were encountered: