Files

10 lines
9.0 KiB
JavaScript
Raw Permalink Normal View History

2025-11-20 09:50:21 +08:00
/*!
* Compressor.js v1.1.1
* https://fengyuanchen.github.io/compressorjs
*
* Copyright 2018-present Chen Fengyuan
* Released under the MIT license
*
* Date: 2021-10-05T02:32:40.212Z
*/
!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 t(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function a(i){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?t(Object(a),!0).forEach(function(e){var t,r;t=i,e=a[r=e],r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):t(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))})}return i}function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}var e,r,o,l,c,h,u,f,i={exports:{}};e=i,"undefined"!=typeof window&&(o=(r=window).HTMLCanvasElement&&r.HTMLCanvasElement.prototype,l=r.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),c=l&&r.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),h=r.BlobBuilder||r.WebKitBlobBuilder||r.MozBlobBuilder||r.MSBlobBuilder,u=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,f=(l||h)&&r.atob&&r.ArrayBuffer&&r.Uint8Array&&function(e){var t,r,i,a,n,o=e.match(u);if(!o)throw new Error("invalid data URI");for(t=o[2]?o[1]:"text/plain"+(o[3]||";charset=US-ASCII"),i=!!o[4],o=e.slice(o[0].length),r=(i?atob:decodeURIComponent)(o),i=new ArrayBuffer(r.length),a=new Uint8Array(i),n=0;n<r.length;n+=1)a[n]=r.charCodeAt(n);return l?new Blob([c?a:i],{type:t}):((o=new h).append(i),o.getBlob(t))},r.HTMLCanvasElement&&!o.toBlob&&(o.mozGetAsFile?o.toBlob=function(e,t,r){var i=this;setTimeout(function(){r&&o.toDataURL&&f?e(f(i.toDataURL(t,r))):e(i.mozGetAsFile("blob",t))})}:o.toDataURL&&f&&(o.msToBlob?o.toBlob=function(e,t,r){var i=this;setTimeout(function(){(t&&"image/png"!==t||r)&&o.toDataURL&&f?e(f(i.toDataURL(t,r))):e(i.msToBlob(t))})}:o.toBlob=function(e,t,r){var i=this;setTimeout(function(){e(f(i.toDataURL(t,r)))})})),e.exports?e.exports=f:r.dataURLtoBlob=f);function j(e){return 0<e&&e<1/0}var T=i.exports,d={strict:!0,checkOrientation:!0,maxWidth:1/0,maxHeight:1/0,minWidth:0,minHeight:0,width:void 0,height:void 0,resize:"none",quality:.8,mimeType:"auto",convertTypes:["image/png"],convertSize:5e6,beforeDraw:null,drew:null,success:null,error:null},m="undefined"!=typeof window&&void 0!==window.document?window:{},p=Array.prototype.slice;var b=/^image\/.+$/;function R(e){return b.test(e)}var g=String.fromCharCode;var y=m.btoa;function w(e,t){for(var r,i=[],a=new Uint8Array(e);0<a.length;)i.push(g.apply(null,(r=a.subarray(0,8192),Array.from?Array.from(r):p.call(r)))),a=a.subarray(8192);return"data:".concat(t,";base64,").concat(y(i.join("")))}function v(e){var t,r,i,a,n,o,s,l=new DataView(e);try{if(255===l.getUint8(0)&&216===l.getUint8(1))for(var c=l.byteLength,h=2;h+1<c;){if(255===l.getUint8(h)&&225===l.getUint8(h+1)){r=h;break}h+=1}if(r&&(a=r+10,"Exif"===function(e,t,r){var i,a="";for(r+=t,i=t;i<r;i+=1)a+=g(e.getUint8(i));return a}(l,r+4,4)&&(!(s=18761===(n=l.getUint16(a)))&&19789!==n||42!==l.getUint16(a+2,s)||8<=(o=l.getUint32(a+4,s))&&(i=a+o))),i)for(var u,f=l.getUint16(i,s),d=0;d<f;d+=1)if(u=i+12*d+2,274===l.getUint16(u,s)){u+=8,t=l.getUint16(u,s),l.setUint16(u,1,s);break}}catch(e){t=1}return t}var U=/\.\d*(?:0|9){12}\d*$/;function k(e,t){t=1<arguments.length&&void 0!==t?t:1e11;return U.test(e)?Math.round(e*t)/t:e}function x(e,t){var r=e.aspectRatio,i=e.height,a=e.width,n=1<arguments.length&&void 0!==t?t:"none",o=j(a),e=j(i);return o&&e?(t=i*r,