When trying to read image data from a canvas which was painted an image upon beforehand, Google Chrome raises a cross origin exception (complaining about the canvas being "tainted"). The directory structure is as follows.
/html/base/path
|-- index.html contains the canvas element, references the script.js
|-- script.js loads imgs/images.jpg, paints and queries the canvas
`-- imgs/image.jpg
The error occurs only when the page was loaded by the file:// scheme.
I wonder whether this is a Chrome bug. If not, which rules do apply? Are there any workarounds?
Unfortunately, off-line viewing is the ultimate use case, so
- the file:// scheme is indispensable
- there is no control over browser settings at the target system.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…