-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
242 lines (208 loc) · 7.06 KB
/
Copy pathindex.html
File metadata and controls
242 lines (208 loc) · 7.06 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<meta name="author" content="tom yuan"/>
<meta property="og:title" content="ImageEditor Of Lightsaber"/>
<meta property="og:image" content="img/Lightsaber_blue.png" />
<meta property="og:description" content="Hello, This is a sample of image editor i made by jquery ui and html5 canvas for generator image file." >
<title>ImageEditor Of Lightsaber(Demo)</title>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-71736556-1', 'auto');
ga('send', 'pageview');
</script>
<link rel="stylesheet" type="text/css" href="css/jquery.ui.core.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.ui.resizable.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header>
<h1>Image upload and edit</h1>
</header>
<section>
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="preview_image">
<!-- <label class="choose_file" for="upload">upload file</label> -->
<div id="pw_image" class="pw_image">
<!-- draggable image -->
<div class="draggable ui-widget-content ">
<div class="santaHat"></div>
</div>
<div class="draggable ui-widget-content ">
<div class="resizable LightsaberBlue"></div>
</div>
</div>
</div>
</div>
<div class="col-md-12 col-sm-12 col-xs-12">
<!-- <div class="itemContent">
<ul class="itemList">
<li ><img src="img/Lightsaber_red.png"></li>
<li ><img src="img/Lightsaber_blue.png"></li>
<li ><img src="img/santa-hat.png"></li>
</ul>
</div><br> -->
<div class="infoContent">
<p>Instruction:</p>
<ol>
<li>upload image</li>
<li>dragging or resizing Lightsaber and santa hat</li>
<li>click download button </li>
</ol>
</div>
<form role="form" id="form">
<div class="btn-content">
<div class="upload-btn">
<input type="file" id="upload" accept="image/*">
Click here for upload image.
</div>
<div class="upload-btn">
<input type="file" id="uploadCapture" accept="image/*" capture>
Click here for upload image from Camara(only for moblie).
</div>
<!-- <input type="button" value="click here for upload image" id="upload_btn"> -->
</div>
</form>
<div class="btn-content">
<button id="output">Download Image</button>
<!-- <button id="download">download</button> -->
</div>
</div>
<!-- AddToAny BEGIN -->
<div class="a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_dd" href="https://www.addtoany.com/share"></a>
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_google_plus"></a>
<a class="a2a_button_qzone"></a>
</div>
<!-- AddToAny END -->
</div>
</div>
<div class="loading">
<div class="loading-Content">
<h1>Please Wait For Download Image</h1>
<img src="img/ajax-loader.gif">
</div>
</div>
</section>
<footer>
<p>Create By <a href="http://t1123425.github.io/My-portfolio/index.html" target="_blank">Tom Yuan</a> Click Link can See More!!</p>
</footer>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/html2canvas.js"></script>
<!-- <script type="text/javascript" src="js/html2canvas.svg.js"></script> -->
<script type="text/javascript" src="js/FileSaver2.js"></script>
<script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>
<script type="text/javascript" src="js/jquery.ui.core.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="js/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="js/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="js/jquery.ui.resizable.js"></script>
<script type="text/javascript" src="js/jquery.ui.rotatable.js"></script>
<script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript">
$(function(){
// var _URL = window.URL || window.webkitURL;
$("#upload_btn").click(function(){
$("#upload").trigger("click");
});
$("#upload").change(function(){
var file_org = $(this);
var file = file_org[0].files[0];
var reader = new FileReader();
var image = $("#pw_image");
// var img;
// var width;
// var height;
if(file){
// img = new Image();
// img.onload = function() {
// width = this.width;
// height = this.height;
// console.debug(width);
// $('.preview_image').css("width",""+width+"px");
// $('.preview_image').css("height",""+height+"px");
// };
// img.src = _URL.createObjectURL(file);
reader.readAsDataURL(file);
}else{
image.src = " ";
}
reader.onload = function(e){
$('#pw_image').css('background', 'transparent url('+e.target.result +') center no-repeat');
$('#pw_image').css('background-size','contain');
}
});
$("#uploadCapture").change(function(){
var file_org = $(this);
var file = file_org[0].files[0];
var reader = new FileReader();
var image = $("#pw_image");
// var img;
// var width;
// var height;
if(file){
// img = new Image();
// img.onload = function() {
// width = this.width;
// height = this.height;
// console.debug(width);
// $('.preview_image').css("width",""+width+"px");
// $('.preview_image').css("height",""+height+"px");
// };
// img.src = _URL.createObjectURL(file);
reader.readAsDataURL(file);
}else{
image.src = " ";
}
reader.onload = function(e){
$('#pw_image').css('background', 'transparent url('+e.target.result +') center no-repeat');
$('#pw_image').css('background-size','contain');
}
});
// dragging image
$( ".draggable" ).draggable();
$(".resizable").resizable({
aspectRatio: true,
handles: 'ne, nw, se, sw'
});
$(".santaHat").resizable({
aspectRatio: true,
handles: 'ne, nw, se, sw'
});
$(".resizable").rotatable();
$('.preview_image').mouseenter(function(){
$('.ui-resizable-handle').show();
$('.ui-rotatable-handle').show();
});
$('#output').click(function(){
$('.ui-resizable-handle').hide();
$('.ui-rotatable-handle').hide();
$('.loading').fadeIn();
setTimeout(function(){
$('.loading').hide();
html2canvas(document.getElementById('pw_image'), {
allowTaint:false,
onrendered: function(canvas) {
var img = canvas.toDataURL();
canvas.toBlob(function(blob) {
saveAs(blob, "OutputImage.png");
}, "image/png");
}
});
},1000);
});
});
</script>
</body>
</html>