javascript - How can i "getImageData" from another website? SECURITY_ERR: DOM Exception 18 -


i'm working on online app manipulate images. works fine when doing local files (on server) try source breaks. reason seems security limitation, qoute whatwg:

whenever getimagedata() method of 2d context of canvas element origin-clean flag set false called otherwise correct arguments, method must raise security_err exception.

so wonder can around somehow? images come google api, , want skip saving images if can.

thanks.

since don't have access server(s) source images being pulled from, best bet proxy files through server.

essentially, send ajax request server url of image want data from. server receives request , asks image on behalf. when obtains file, base64 encodes , sends data you. since image data string, can create image object out of , manipulate via canvas without worrying originating domain.

if you're willing use jquery, there's great plugin located here: http://www.maxnov.com/getimagedata/

i've used particular plugin before excellent results. note should (must) host proxy server code on own server. can use author's appspot account, it's limited number of queries per day , runs out. author explains how host proxy code here: http://www.maxnov.com/getimagedata/#using-your-own-server


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -