I want to resize user uploaded images and get a thumbnail and other image dimensions. I use this code to receive uploaded images
var files = fileInput.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
var imageType = /image.*/;
if (!file.type.match(imageType)) {
continue;
}
var img = document.getElementById("thumbnil");
img.file = file;
var reader = new FileReader();
reader.onload = (function(aImg) {
return function(e) {
aImg.src = e.target.result;
};
})(img);
reader.readAsDataURL(file);
}
I want the uploaded image be resized to thumbnail size to 136 × 136 and single image size to 454 × 527 so that I can save them to the database. How can I adjust the code to resize the image?