-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
70 lines (64 loc) · 1.79 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="edit-Type" edit="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="resizer/croppie.css" rel="stylesheet"/>
<title>Resizer</title>
<style type="text/css" media="screen">
#my-image, #use {
display: none;
}
</style>
<script
type="text/javascript"
src="resizer/jquery-2.2.4.js">
</script>
<script src="resizer/croppie.js"></script>
<script type="text/javascript">
window.onload=function(){
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#my-image').attr('src', e.target.result);
var resize = new Croppie($('#my-image')[0], {
viewport: { width: 100, height: 100 },
boundary: { width: 800, height: 500 },
showZoomer: false,
enableResize: true,
enableOrientation: true
});
$('#use').fadeIn();
$('#use').on('click', function() {
resize.result('base64').then(function(dataImg) {
var data = [{ image: dataImg }, { name: 'myimgage.jpg' }];
// use ajax to send data to php
$('#result').attr('src', dataImg);
})
})
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function() {
readURL(this);
});
}
</script>
</head>
<body>
<table align="center"><tr><td>
<form id="form1" runat="server">
<input type='file' id="imgInp" />
<img id="my-image" src="#" align="left"/>
</form></td></tr>
<tr><td>
<button id="use">Crop</button></td></tr>
<tr><td>
<img id="result" src="" align="left">
</td></tr></table>
</body>
</html>