@awesome-compressor/browser-compress-image
Version:
🚀 A powerful, lightweight browser image compression library with TypeScript support. Compress JPEG, PNG, GIF images with multiple output formats (Blob, File, Base64, ArrayBuffer) and zero dependencies.
1 lines • 705 B
JavaScript
import{__esmMin as e,__export as t}from"./chunk-BFNP_Rck.js";import n from"compressorjs";var r={};t(r,{default:()=>i});async function i(e,t){let{quality:r,mode:i,targetWidth:a,targetHeight:o,maxWidth:s,maxHeight:c,preserveExif:l=!1}=t;if(!e.type.includes(`jpeg`)&&!e.type.includes(`jpg`))throw Error(`CompressorJS is optimized for JPEG files`);return new Promise((t,u)=>{let d={quality:r,retainExif:l,mimeType:e.type,success:n=>{let r=n;r.size>=e.size*.98?t(e):t(r)},error:u};i===`keepQuality`&&(a&&(d.width=a),o&&(d.height=o),s&&(d.maxWidth=s),c&&(d.maxHeight=c)),new n(e,d)})}var a=e(()=>{});export{i as compressWithCompressorJS,r as compressWithCompressorJS_exports,a as init_compressWithCompressorJS};