@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 665 B
JavaScript
import e from"mime-types";const t=async(t,n)=>{try{let r=await import(`sharp`),i=r.default();t.pipe(i),n.format&&i.toFormat(n.format,{quality:n.quality?n.quality:80}),(n.width||n.height)&&i.resize({width:n.width?n.width:void 0,height:n.height?n.height:void 0});let a=await i.toBuffer(),o=e.lookup(n.format||`jpg`)||`image/jpeg`;return{error:void 0,data:{buffer:a,mimeType:o,size:a.length,extension:e.extension(o)||`jpg`,shouldStore:!0}}}catch(e){return{error:{type:`basic`,message:e?.message||`An error occurred while processing the image with Sharp`},data:void 0}}};var n=t;export{n as sharp_processor_default};
//# sourceMappingURL=sharp-processor-BCi9CFoT.js.map