Compres images on browser with javascript
var imageSource = 'http://www.mysite.com/my-image.jpg'; // base64 or link
// source, dimension, compression, success, error
$image.resize(imageSource, {width: 340, height: 340}, 0.4, function(file) {
console.log('Image base64:');
console.log(file);
}, function() {
console.error('Error!!');
});
let imageSource = 'http://www.mysite.com/my-image.jpg'; // base64 or link
$image.resize(imageSource, {width: 340, height: 340}, 0.4, (file) => {
console.log(`Image base64: ${file}`);
}, () => {
console.error('Error!!');
});