/* eslint-disable */
export default function imgCompress(file, resolution, quality) {
    if (resolution === void 0) { resolution = 500; }
    if (quality === void 0) { quality = 1; }
    return new Promise(function (resolve, reject) {
        var tmpImage = new Image();
        tmpImage.src = file;
        tmpImage.onload = function () {
            var width = tmpImage.width;
            var height = tmpImage.height;
            var rare = resolution / width;
            var canvas = document.createElement('canvas');
            var ctx = canvas.getContext('2d');
            canvas.width = width * rare;
            canvas.height = height * rare;
            ctx && ctx.drawImage(tmpImage, 0, 0, width * rare, height * rare);
            var res = canvas.toDataURL('image/jpeg', quality);
            if (res) {
                resolve(res);
            }
            else {
                reject(res);
            }
        };
    });
}
