{"id":41489,"date":"2021-05-10T10:58:52","date_gmt":"2021-05-10T10:58:52","guid":{"rendered":"https:\/\/www.oracletutoring.ca\/blog\/?p=41489"},"modified":"2021-05-10T10:58:53","modified_gmt":"2021-05-10T10:58:53","slug":"web-programming-cross-origin-blockage-with-getimagedata-or-putimagedata","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/web-programming-cross-origin-blockage-with-getimagedata-or-putimagedata\/","title":{"rendered":"Web programming: cross-origin blockage with getImageData or putImageData"},"content":{"rendered":"\n<h2>Self-tutoring about how to deal with cross-origin denial: the tutor mentions a workaround.<\/h2>\n<p>I was experimenting with html canvas, specifically getImageData and putImageData, when I got a cross-origin complaint. The computer wouldn&#8217;t execute either getImageData or putImageData because, from its point of view, the file telling it to and the image file weren&#8217;t from the same origin. Such was my understanding, anyway.<\/p>\n<p>Yet, what to do? I needed to perform a few tests, so needed those commands to work.<\/p>\n<p>BTW: both files <em>were<\/em> from the same origin, even the same folder, on the computer I was using. However, I came to understand that JavaScript, for security reasons, is quite limited in working with local files.<\/p>\n<p>In the end I uploaded both the script and the image file to the same folder on a server. JavaScript perceived those as from the same origin so then getImageData and putImageData worked.<\/p>\n<p>Source:<\/p>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CanvasRenderingContext2D\/getImageData\">developer.mozilla.org<\/a><\/p>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Security\/Same-origin_policy\">developer.mozilla.org<\/a><\/p>\nJack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.\n","protected":false},"excerpt":{"rendered":"<p>Self-tutoring about how to deal with cross-origin denial: the tutor mentions a workaround. I was experimenting with html canvas, specifically getImageData and putImageData, when I got a cross-origin complaint. The computer wouldn&#8217;t execute either getImageData or putImageData because, from its &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/web-programming-cross-origin-blockage-with-getimagedata-or-putimagedata\/\"> <span class=\"screen-reader-text\">Web programming: cross-origin blockage with getImageData or putImageData<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[],"class_list":["post-41489","post","type-post","status-publish","format-standard","hentry","category-computer-science"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=41489"}],"version-history":[{"count":3,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41489\/revisions"}],"predecessor-version":[{"id":41492,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41489\/revisions\/41492"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=41489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=41489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=41489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}