On 29.05.17 16:41, Andrew Hankinson wrote:
>>
https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image
[...]
That is correct. I meant that the request starts to be subject to CORS
which a simple img-request isn't.
> If we were to try and do that with image content from a different domain, the browser would complain about a tainted canvas and refuse to load the image.
The MDN reference above says "Once a canvas has been tainted, you can no
longer pull data back out of the canvas. For example, you can no longer
use the canvas toBlob(), toDataURL(), or getImageData() methods; doing
so will throw a security error." Do you use any of these methods on the
canvas?
I commented out the image.crossOrigin = "anonymous" and the images start
to work for me in diva.js without CORS on the image requests. I haven't
done any extensive testing though.
There seems to be already be diva issue #367 that makes crossOrigin an
option: <
https://github.com/DDMAL/diva.js/issues/367>. Maybe it should
be the default if it has no ill consequences.
>> I don't think that any image-crossorigin settings would help me. Could I
>> set the client so that it does not require a CORS header?
>
> CORS security is baked into the browser. My understanding is that you cannot load images across origins unless you have both the image set to 'anonymous' and the server providing "Access-Control-Allow-Origin *" on the image resources, since the browser will treat this as an effort to taint the canvas and fail to work.
It seems that you can use images across origins but you have to live
with a tainted canvas ;-)
>> How have you set up your IIIF image server? Do you supply CORS on all
>> image requests? Or do you just run you scripts on the same server?
>
> For examples like this one:
>
>
http://ddmal.github.io/diva.js/try/demo/iiif-external.html
>
> Looking at the server response from the BnF for Latin 12044 example, you can see that they serve the images with "Access-Control-Allow-Origin *" for their image results.
If ACAO=* needs to be the default for image request then this should be
in the next revision of the IIIF Image API spec (and in the notes for
the current spec).
>> Am I the only one that has this problem?
>
> CORS is not the friendliest spec to understand. I think it's as confusing to everyone else as it is to me too. :)
That is true %-) On top of being hard to read it also sprouts new
extensions over time like the img-request suddenly being subject to CORS
when its used in a canvas which I had not encountered before.
Cheers
Robert
--
Dr. Robert Casties -- Information Technology Group
Max Planck Institute for the History of Science
Boltzmannstr. 22, D-14195 Berlin
Tel: +49/30/22667-342 Fax: -299