С помощью этой функции вы можете сжимать изображения
function compress(source_img_obj, quality, output_format, callback) {
var mime_type = "image/jpeg";
if (output_format == "png") {
mime_type = "image/png";
}
var image = new Image();
image.onload = function() {
var cvs = document.createElement('canvas');
cvs.width = image.naturalWidth;
cvs.height = image.naturalHeight;
var ctx = cvs.getContext("2d").drawImage(image, 0, 0);
var newImageData = cvs.toDataURL(mime_type, quality / 100);
var result_image_obj = new Image();
result_image_obj.src = newImageData;
callback(result_image_obj);
};
image.src = source_img_obj
}
var fileReference = document.getElementById("fileName").files[0];
compress(window.URL.createObjectURL(fileReference), 70, "jpeg",
function(img){
console.log(img.src); // (Base64)
})