-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
74 lines (64 loc) · 2.11 KB
/
index.html
File metadata and controls
74 lines (64 loc) · 2.11 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="telephone=no" name="format-detection">
<meta content="false" id="twcClient" name="twcClient">
<title></title>
<script type="text/javascript" src="js/libs/jquery.js"></script>
<script type="text/javascript" src="js/exif.js"></script>
<script type="text/javascript" src="js/compress.js"></script>
<script type="text/javascript">
$(function(){
var photo = new ImgCompressor("#photoFile", {
"preview": "#imgPreview",
"callback": function(data) {
$("#imgPreview").attr("src", data.images[0]);
}
});
})
</script>
<script type="text/javascript">
$(function() {
// $("#photoFile").change(function(e) {
// console.log(new Date().getTime());
// photoHandle(e.target.files[0]);
// // var url = window.URL.createObjectURL($(this)[0].files[0]);
// // console.log(url);
// // $("#imgPreview").attr("src", url);
// });
})
var photoHandle = function(param) {
if(param) {
EXIF.getData(param, function() {
console.log(EXIF.getTag(this, "Orientation"));
window.URL = window.URL || window.webkitURL;
var url = window.URL.createObjectURL(param);
var canvas = $("<canvas id='img_canvas'></canvas>")[0];
var img = new Image();
img.onload = function() {
var width = this.width;
var height = this.height;
var ctx = canvas.getContext("2d");
canvas.width = width;
canvas.height = height;
ctx.drawImage(img, 0, 0, width, height);
var base64 = canvas.toDataURL("image/jpeg", 3);
canvas.remove();
console.log(base64);
console.log(new Date().getTime());
$("#imgPreview").attr("src", base64);
}
img.src = url;
});
}
}
</script>
</head>
<body>
<input type="file" multiple="multiple" id="photoFile" accept="image/*" />
<img src="" id="imgPreview" width="480" height="320" style="border:none;" />
</body>
</html>