-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.htm
More file actions
43 lines (36 loc) · 1.25 KB
/
Copy patha.htm
File metadata and controls
43 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!doctype html>
<html>
<head>
<script>
var BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder || window.BlobBuilder;
getPic = function(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
// Copy the image contents to the canvas
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
// atob to base64_decode the data-URI
var d = canvas.toDataURL("image/png").replace(/^data:image\/[^;]/, 'data:application/octet-stream');
location.href = d
/* var image_data = atob(d.split(',')[1]);
// Use typed arrays to convert the binary data to a Blob
var arraybuffer = new ArrayBuffer(image_data.length);
var view = new Uint8Array(arraybuffer);
for (var i=0; i<image_data.length; i++) {
view[i] = image_data.charCodeAt(i) & 0xff;
}
var bb = new BlobBuilder();
bb.append(arraybuffer);
var blob = bb.getBlob(); // <-- Here's the Blob!
// Use the URL object to create a temporary URL
var URL = (window.webkitURL || window.URL).createObjectURL(blob);
location.href = URL; // <-- Download!
*/
};
</script>
</head>
<body>
<img src="askmefi.png" onClick=getPic(this)>
</body>
</html>