Problem
- i have Reffred Link :https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image.
- https://github.com/h5bp/server-configs-apache/blob/fc379c45f52a09dd41279dbf4e60ae281110a5b0/src/.htaccess#L36-L53
/etc/apache2/apache2.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch "\.(cur|gif|ico|jpe?g|png|svgz?|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
</Directory>
- start the apache again .
Bug:
Uncaught SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
Code
var image = ctx.getImageData(0, 0, canvas.width, canvas.height),//debugger breakpoint stop here.
imageData = image.data;
Debug solution
- i have googled and find that no browser will allow cross origin images.
- i don"t need to save images of cross origin .
- change in .htaccess file.
- how to debug the issue.