LarpixClient/node_modules/super-image-cropper/esm/lib/synthetic-gif.js
olcxja 95aaaa69ea big updat:
- update dependencies
- add webp support and webp conversion for profile images
2026-07-02 22:40:46 +02:00

2 lines
1.1 KiB
JavaScript

import{transformToUrl as t}from"gif-build-worker-js";import s from"gif.js";import{OutputType as e}from"../index.js";class r{cropperJsOpts;frames;frameDelays;gifJsOptions;outputType;constructor({frames:t,commonCropOptions:s,frameDelays:e,gifJsOptions:r={},outputType:o}){this.cropperJsOpts=s.cropperJsOpts,this.frames=t,this.frameDelays=e,this.gifJsOptions=r,this.outputType=o}bootstrap(){return new Promise(((r,o)=>{const i=t(),p=Object.assign({workers:2,quality:10,workerScript:i,width:this.cropperJsOpts.width,height:this.cropperJsOpts.height,transparent:"transparent"},this.gifJsOptions||{}),a=new s(p);a.on("finished",(t=>{if(this.outputType===e.BLOB)r(t);else if(this.outputType===e.BASE64)r(this.convertBlob2Base64(t));else{const s=window.URL.createObjectURL(t);r(s)}})),this.frames.forEach(((t,s)=>{a.addFrame(t,{delay:this.frameDelays[s],copy:!0})})),a.render()}))}convertBlob2Base64(t){return new Promise(((s,e)=>{const r=new FileReader;r.onload=function(t){s(t?.target?.result)},r.onerror=t=>{e(t)},r.readAsDataURL(t)}))}}export{r as SyntheticGIF};
//# sourceMappingURL=synthetic-gif.js.map