const files = this.refs.fileInput.files;
if (!files.length) return;
for (let i = 0; i < files.length; i++) {
const reader = new FileReader(),
image = new Image();
image.onload = () => resizeAndStore(image);
reader.onloadend = () => image.src = reader.result;
reader.readAsDataURL(files[i]);
}var xhr = new XMLHttpRequest(),
method = "GET",
url = "https://developer.mozilla.org/";
xhr.open(method, url, true);
xhr.onreadystatechange = function () {
if(xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.responseText);
}
};
xhr.send();const canvas1 = document.createElement('canvas'),
canvas2 = document.createElement('canvas'),
ctx1 = canvas1.getContext('2d');
let ratio = 1;
if (bitmap.width > bitmap.height) {
if (bitmap.width > lib.maxImgWidth)
ratio = lib.maxImgWidth / bitmap.width;
} else {
if (bitmap.height > lib.maxImgHeight)
ratio = lib.maxImgHeight / bitmap.height;
}
canvas1.height = bitmap.height;
canvas1.width = bitmap.width;
ctx1.drawImage(bitmap, 0, 0);
canvas2.height = bitmap.height * ratio;
canvas2.width = bitmap.width * ratio;
pica.resize(canvas1, canvas2)
.then(result => pica.toBlob(result, 'image/jpeg', 90))Webpack
LESS/SASS
NPM/Bower