I am quite new to doing thing with uploading etc. But currently I am building an application that can capture a picture to send it to a database for further use (which is irrelevant for this). When I capture a image and try to upload it it takes alot of time. So I would like to compress the image, before uploading it. But I cant figure out how to acomplisch this.
This is the code that I have for the image capturing:
HTML:
<input type="file" accept="image/*" id="capture" capture="camera">
JS:
document.getElementById('capture').onchange = function(){
var reader = new FileReader();
reader.onload = function(e){
$('.field-wrapper.camera').css('background-image', 'url('+e.target.result+')')
$('.camera-icon').hide();
imageUrl = e.target.result;
};
reader.readAsDataURL(this.files[0]);
}
Anyone who can help me with compressing my image before uploading? Would be greatly appreciated! :)