/*! * Compressor.js v1.0.7 * https://fengyuanchen.github.io/compressorjs * * Copyright 2018-present Chen Fengyuan * Released under the MIT license * * Date: 2020-11-28T07:13:17.754Z */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Compressor=t()}(this,function(){"use strict";function n(e,t){for(var r=0;rf.convertSize&&"image/png"===f.mimeType&&(v="#fff",f.mimeType="image/jpeg"),m.fillStyle=v,m.fillRect(0,0,o,e),f.beforeDraw&&f.beforeDraw.call(this,m,d),this.aborted||(m.save(),m.translate(o/2,e/2),m.rotate(i*Math.PI/180),m.scale(l,c),m.drawImage(h,w,g,n,y),m.restore(),f.drew&&f.drew.call(this,m,d),this.aborted||(m=function(e){t.aborted||t.done({naturalWidth:r,naturalHeight:a,result:e})},d.toBlob?d.toBlob(m,f.mimeType,f.quality):m(U(d.toDataURL(f.mimeType,f.quality)))))}},{key:"done",value:function(e){var t=e.naturalWidth,r=e.naturalHeight,a=e.result,n=this.file,i=this.image,e=this.options;g&&!e.checkOrientation&&g.revokeObjectURL(i.src),!a||e.strict&&a.size>n.size&&e.mimeType===n.type&&!(e.width>t||e.height>r||e.minWidth>t||e.minHeight>r)?a=n:(r=new Date,a.lastModified=r.getTime(),a.lastModifiedDate=r,a.name=n.name,a.name&&a.type!==n.type&&(a.name=a.name.replace(y,("jpeg"===(n=B(n=a.type)?n.substr(6):"")&&(n="jpg"),".".concat(n))))),this.result=a,e.success&&e.success.call(this,a)}},{key:"fail",value:function(e){var t=this.options;if(!t.error)throw e;t.error.call(this,e)}},{key:"abort",value:function(){this.aborted||(this.aborted=!0,this.reader?this.reader.abort():this.image.complete?this.fail(new Error("The compression process has been aborted.")):(this.image.onload=null,this.image.onabort()))}}])&&n(e.prototype,t),a&&n(e,a),r}()});