exupero / saveSvgAsPng

Save SVGs as PNGs from the browser.
MIT License
1.09k stars 362 forks source link

Could not load <image url> (sandbox example) #220

Open rdecapomaranca opened 5 years ago

rdecapomaranca commented 5 years ago

Hi.

I pasted the following svg code in the Sandbox:

`

`

On "Preview" I get the correct output but in console I get an error: Error: Could not load http://www.simpleimageresizer.com/static/images/simple-image-resizer-128x128.png?t=1557241604986

And on "Save as PNG" nothing happens just the console outputs the same error again.

Any idea on why this happens?

Thank you, Nika

ligaz commented 5 years ago

It looks like it is a CORS issue. simpleimageresizer.com is not serving the allow origin header for the image.

Quoting MDN:

If the server does not give credentials to the origin site (by not setting the Access-Control-Allow-Origin HTTP header), the image will be tainted and its usage restricted.

rdecapomaranca commented 5 years ago

But doesn't that mean that the image shouldn't have loaded at all? Because when looking at the Network section (see image below), the image is loaded successfully on both "Preview" and "Save as PNG". I would expect and error if it was a CORS issue.

Screenshot

ligaz commented 5 years ago

It's a JavaScript error. You can examine it in the Console tab.