-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
49 lines (49 loc) · 1.33 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Uploader</title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
<style>
*{
margin: 0;
padding: 0;
}
img{
display: block;
width: 400px;
}
</style>
</head>
<body>
<input type="file" name="" id="">
<img src="" alt="">
<script src="//cdn.staticfile.org/exif-js/2.3.0/exif.min.js"></script>
<script src="//unpkg.com/Imager@0.1.6/dist/Imager.min.js"></script>
<script>
var fileInput, img
fileInput = document.querySelector('input[type=file]')
img = document.querySelector('img')
fileInput.addEventListener('change', function(e){
var file, imager
file = e.target.files[0]
if(file){
if(window.Imager.isImage(file)) {
imager = new window.Imager({
file: file,
quality: 1,
isLimit: false
})
imager.getExif().then(data => {
return imager.loaded()
}).then(base64 => {
img.src = base64
})
} else {
console.log('不是图片')
}
}
})
</script>
</body>
</html>