Comments (12)
It will not work this way because the image is served from a different domain than the script. The script performs XMLHttpRequest to get the image data, and request will rather not succeed.
See request headers (pay attention to the Origin field):
GET /eQxoG0h.jpg HTTP/1.1
Host: i.imgur.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://run.plnkr.co/wrtWddsqSpO1Cd9b/
Origin: http://run.plnkr.co
Connection: keep-alive
Here is the error you get on console:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://imgur.com/eQxoG0h. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
So, you will not get this image rendered, as the script simply does not have access to it. I believe you're having the same problem as in issue #22
from dom-to-image.
I struggled with this for a while, I was the person who opened issue #22. The problem is that the XMLHttpRequest is very strict on the kinds of headers it wants back. The person who runs the server with the resource being denied may not be so strict (I mean you Amazon S3). The way I dealt with it was to change the original URL on the page to a 'mirror' URL that worked through a GET API on my server, where I can control the headers, and just run all the resources through that. Hope that helps.
from dom-to-image.
What I expect is
when one of images has CORS issue, it's better to render without that image instead of stopping the whole operation without giving the detailed error message.
Yes "I will not get this image rendered", but how about others?
My web page may have hundreds of images with one external image link, then I still want to have the whole screen shot without the image.
from dom-to-image.
OK, I've missed the fact that you're actually getting an error instead of of the rendering result. Another interesting thing is - this example works on Chrome, event without any CORS issues. Will take a look at that.
from dom-to-image.
Hello, I am having an issue with firefox 46.0.1. I am having image converted like this
Also know that,some images are flipped horizontally.
Can you please help? Thanks
from dom-to-image.
@RedsaiyanAlpha please provide a jsfiddle or something like that
from dom-to-image.
Please check https://jsfiddle.net/w9hs8yzr/2/
from dom-to-image.
Any Update?
from dom-to-image.
Sorry, currently I'm travelling, but will definitely take a look next week.
On May 16, 2016 8:15 AM, "RedsaiyanAlpha" [email protected] wrote:
Any Update?
—
You are receiving this because you were assigned.
Reply to this email directly or view it on GitHub
#29 (comment)
from dom-to-image.
Thanks. Enjoy!
from dom-to-image.
@RedsaiyanAlpha sorry for delay. Your jsfiddle gives me an error
ReferenceError: domtoimage is not defined
conversion() _display:88
1 _display:88:16
you might want to take a look at this example fiddle http://jsfiddle.net/tsayen/8h13tmcj/2/ on how to load and use the lib
from dom-to-image.
Hello, find same error when load image from different origin.
from dom-to-image.
Related Issues (20)
- Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. HOT 2
- Most of the issues have been fixed in forked library `modern-screenshot` HOT 4
- toPng() throw error. HOT 8
- Super long HTML growth chart - Node images with height exceeding 16000 are blank HOT 2
- DomToPNG not working if dom contains %BB
- dom to image giving blank images HOT 3
- How to keep ratio without adding blank space around the image HOT 1
- Rendering svg
- The internal picture is blank
- Cookies not passed to image request
- It not support xlink:href for svg? HOT 1
- When there is a large DOM content, empty file download happening. Are there any limitations? HOT 3
- the image some time cutting and some time show correct HOT 1
- sometimes image in HTML is big,domtoimage will show blank image in IOS not Android
- DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported
- DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported HOT 1
- Full Scrollable (CLOSED)
- shadow-root not rendered. HOT 1
- Exporting to PNG does not check checkboxes
- domtoimage doesn't work on vector layer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dom-to-image.