[fix] uploaded images should have the right height

This commit is contained in:
alban 2020-11-17 22:18:08 +01:00
parent 663180c84a
commit e59bd0bfc5

View File

@ -47,6 +47,7 @@ $(document).ready(function(){
}
function showSnap(src, width, height){
canvas.height = height
cropper && cropper.destroy()
snapContext.drawImage(src, 0, 0, width, height);
snap = snapContext.createImageData(width, height);
@ -99,9 +100,21 @@ $(document).ready(function(){
function processFiles(files) {
var file, img;
var _URL = window.URL || window.webkitURL;
if ((file = files[0])) {
img = new Image();
var objectUrl = _URL.createObjectURL(file);
img.onload = function () {
let w = 640
let h = 640 * this.height / this.width
showSnap(this,w,h)
};
img.src = objectUrl;
}
if(files && typeof FileReader !== "undefined") {
for(var i=0; i<files.length; i++) {
fileToSnap(files[i]);
// fileToSnap(files[i]);
}
}
}
@ -112,6 +125,9 @@ $(document).ready(function(){
reader.onload = function(e) {
let base_image = new Image();
base_image.src = e.target.result;
console.log(
base_image.width
)
base_image.width = 640;
base_image.onload = function(){
showSnap(base_image,640,480)