blob: c59b95594ff505913e856377459eba28b00b8c6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<script>
function load_multipart_image(src) {
return new Promise((resolve, reject) => {
const img = document.createElement('img');
img.addEventListener('load', () => resolve(img));
img.addEventListener('error', (e) => reject(new DOMException('load failed', 'NetworkError')));
img.src = src;
});
}
function get_image_data(img) {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
context.drawImage(img, 0, 0);
// When |img.src| is cross origin, this should throw a SecurityError.
const imageData = context.getImageData(0, 0, 1, 1);
return imageData;
}
</script>
|