Skip to content
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

svgEditor.svgCanvas.rasterExport("PNG", 100) does not include images #1002

Closed
alexm7 opened this issue Oct 24, 2024 · 4 comments
Closed

svgEditor.svgCanvas.rasterExport("PNG", 100) does not include images #1002

alexm7 opened this issue Oct 24, 2024 · 4 comments
Labels

Comments

@alexm7
Copy link

alexm7 commented Oct 24, 2024

**PLEASE NOTE: We are trying to make this project live again. While you can file an issue, we will do our best but you should not expect any action, even if we label the issue. However, we are welcoming new contributors **

Describe the bug
I have a simple svg that I am editing. It is basically a image and on top of that the user draws a bunch of lines. The SVG that I open the SVG-Edit with is like:
<svg width="840" height="1269" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g class="layer"> <title>Layer 1</title> <image height="1269" href="/cc/pics/a5f/a5f5f32bc17ea3d7ce42bd80015f2f49-840-1269.jpg" id="svg_1" width="840"/> </g></svg>
The user then draws on the image resulting in an exported SVG like:
<svg width="840" height="1269" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <g class="layer"> <title>Layer 1</title> <image height="1269" href="/cc/pics/a5f/a5f5f32bc17ea3d7ce42bd80015f2f49-840-1269.jpg" id="svg_1" width="840"/> <path d="m635,692c-14,-7.83 -17.45,-9.51 -21.39,-11.33c-4.33,-2 -9,-4.09 -13.96,-6.17c-5.14,-2.15 -10.41,-4.29 -15.81,-6.17c-10.6,-3.69 -15.84,-5.02 -20.93,-6.16c-4.95,-1.11 ............." fill="none" id="svg_2" stroke="#000000" stroke-width="5"/> </g></svg>
I have added a javascript onclick() method that creates a raster export to a PNG of the SVG-Edit canvas. This is done with code like:

function onClick() {
	svgEditor.svgCanvas.bind('exported', function (win, data) { saveData(svgEditor.svgCanvas.getSvgString(), data); });
	pngImage = svgEditor.svgCanvas.rasterExport("PNG", 100);
}

The created PNG file contains only the <path ...> elements. It does not rasterize the <image> element. I would like to correct this so that the rasterExport contains everything.

To Reproduce
See description above.

Expected behavior
I believe rasterExport("PNG", 100) should generate a raster of the entire svgcanvas which includes both the <image> and other tags.

SVG-Edit environment (IMPORTANT)

  • File for SVG-Edit: ???
  • Version: current "master" from github as of 2024/10/23
  • Protocol: http

Desktop (please complete the following information):

  • OS: Linux
  • Browser Firefox
  • Version 131.0.1

Smartphone (please complete the following information):
NA

Screenshots

Log

Additional context

@jfhenon
Copy link
Collaborator

jfhenon commented Oct 26, 2024

You are right. This bug is linked to the fact that URL are restricted by CORS restriction of browsers.
I will make a change to transform the imbedded file as base64 just before export.
This should fix your issue without collateral issues.

@alexm7
Copy link
Author

alexm7 commented Oct 26, 2024

Cool. Thanks!

@jfhenon
Copy link
Collaborator

jfhenon commented Oct 26, 2024

Please close the issue when it's confirmed.

@alexm7
Copy link
Author

alexm7 commented Oct 26, 2024

Closing this issue and tracking on #1003

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

No branches or pull requests

2 participants