beautiful-image 0.2.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./image-processor-hqbPBWVw.cjs");let h=!1;async function u(){h||(await a.__wbg_init(),h=!0)}class d extends a.ImageProcessor{constructor(n){super(n)}async toJpeg(n){await u();const t=await createImageBitmap(this.file),l=t.height/t.width,e=this.targetWidth?Math.min(this.targetWidth,t.width):t.width,s=Math.round(e*l),i=new OffscreenCanvas(e,s).getContext("2d");i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high",i.drawImage(t,0,0,e,s);const m=i.getImageData(0,0,e,s),p=new Uint8Array(m.data.buffer),r=a.processImage(p,e,s,n,this.ops.sharpenSigma??null,this.ops.sharpenThreshold??null,this.ops.blurSigma??null,this.ops.brightness??null,this.ops.contrast??null,this.ops.grayscale,this.ops.invert,this.ops.hueRotate??null);t.close();const c=this.file.size,g=r.length;return{blob:new Blob([new Uint8Array(r)],{type:"image/jpeg"}),originalSize:c,optimizedSize:g,compressionRatio:1-g/c,width:e,height:s}}}const w=o=>new d(o);exports.processImage=a.processImage;exports.image=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./image-processor-SsMTFAkc.cjs");let h=!1;async function u(){h||(await a.__wbg_init(),h=!0)}class d extends a.ImageProcessor{constructor(n){super(n)}async toJpeg(n){await u();const t=await createImageBitmap(this.file),l=t.height/t.width,e=this.targetWidth?Math.min(this.targetWidth,t.width):t.width,s=Math.round(e*l),i=new OffscreenCanvas(e,s).getContext("2d");i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high",i.drawImage(t,0,0,e,s);const m=i.getImageData(0,0,e,s),p=new Uint8Array(m.data.buffer),r=a.processImage(p,e,s,n,this.ops.sharpenSigma??null,this.ops.sharpenThreshold??null,this.ops.blurSigma??null,this.ops.brightness??null,this.ops.contrast??null,this.ops.grayscale,this.ops.invert,this.ops.hueRotate??null);t.close();const c=this.file.size,g=r.length;return{blob:new Blob([new Uint8Array(r)],{type:"image/jpeg"}),originalSize:c,optimizedSize:g,compressionRatio:1-g/c,width:e,height:s}}}const w=o=>new d(o);exports.processImage=a.processImage;exports.image=w;
@@ -1,4 +1,4 @@
1
- import { I as m, p as u, _ as d } from "./image-processor-CfaoYWMt.js";
1
+ import { I as m, p as u, _ as d } from "./image-processor-BvZZwU85.js";
2
2
  let c = !1;
3
3
  async function w() {
4
4
  c || (await d(), c = !0);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("node:fs"),m=require("node:url"),l=require("node:path"),s=require("./image-processor-hqbPBWVw.cjs");var i=typeof document<"u"?document.currentScript:null;const h=l.dirname(m.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("beautiful-image.node.cjs",document.baseURI).href));let a=!1;async function f(){if(!a){const t=l.join(h,"../wasm/beautiful_image_bg.wasm"),e=c.readFileSync(t);await s.__wbg_init({module_or_path:e}),a=!0}}class p extends s.ImageProcessor{constructor(e){super(e)}async toJpeg(e){await f();const u=new Uint8Array(this.file.buffer,this.file.byteOffset,this.file.byteLength),n=s.processImageFromBytes(u,this.targetWidth??null,e,this.ops.sharpenSigma??null,this.ops.sharpenThreshold??null,this.ops.blurSigma??null,this.ops.brightness??null,this.ops.contrast??null,this.ops.grayscale,this.ops.invert,this.ops.hueRotate??null),o=this.file.byteLength,r=n.length;return{data:Buffer.from(n),originalSize:o,optimizedSize:r,compressionRatio:1-r/o}}}const d=t=>new p(t);exports.processImageFromBytes=s.processImageFromBytes;exports.image=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("node:fs"),m=require("node:url"),l=require("node:path"),s=require("./image-processor-SsMTFAkc.cjs");var i=typeof document<"u"?document.currentScript:null;const h=l.dirname(m.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("beautiful-image.node.cjs",document.baseURI).href));let a=!1;async function f(){if(!a){const t=l.join(h,"../wasm/beautiful_image_bg.wasm"),e=c.readFileSync(t);await s.__wbg_init({module_or_path:e}),a=!0}}class p extends s.ImageProcessor{constructor(e){super(e)}async toJpeg(e){await f();const u=new Uint8Array(this.file.buffer,this.file.byteOffset,this.file.byteLength),n=s.processImageFromBytes(u,this.targetWidth??null,e,this.ops.sharpenSigma??null,this.ops.sharpenThreshold??null,this.ops.blurSigma??null,this.ops.brightness??null,this.ops.contrast??null,this.ops.grayscale,this.ops.invert,this.ops.hueRotate??null),o=this.file.byteLength,r=n.length;return{data:Buffer.from(n),originalSize:o,optimizedSize:r,compressionRatio:1-r/o}}}const d=t=>new p(t);exports.processImageFromBytes=s.processImageFromBytes;exports.image=d;
@@ -1,7 +1,7 @@
1
1
  import { readFileSync as n } from "node:fs";
2
2
  import { fileURLToPath as l } from "node:url";
3
3
  import { dirname as m, join as h } from "node:path";
4
- import { I as p, a as u, _ as c } from "./image-processor-CfaoYWMt.js";
4
+ import { I as p, a as u, _ as c } from "./image-processor-BvZZwU85.js";
5
5
  const f = m(l(import.meta.url));
6
6
  let r = !1;
7
7
  async function g() {