beautiful-image 0.2.2 → 0.2.4

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.
@@ -0,0 +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,7 +1,5 @@
1
1
  export declare const image: (file: File | Blob) => ImageProcessor<File | Blob, OptimizeResult>;
2
2
 
3
- export declare const imageNode: (file: Buffer | Uint8Array) => ImageProcessorNode;
4
-
5
3
  declare abstract class ImageProcessor<TInput, TResult> {
6
4
  protected file: TInput;
7
5
  protected targetWidth?: number;
@@ -18,18 +16,6 @@ declare abstract class ImageProcessor<TInput, TResult> {
18
16
  abstract toJpeg(quality: number): Promise<TResult>;
19
17
  }
20
18
 
21
- declare class ImageProcessorNode extends ImageProcessor<Buffer | Uint8Array, NodeOptimizeResult> {
22
- constructor(file: Buffer | Uint8Array);
23
- toJpeg(quality: number): Promise<NodeOptimizeResult>;
24
- }
25
-
26
- export declare interface NodeOptimizeResult {
27
- data: Buffer;
28
- originalSize: number;
29
- optimizedSize: number;
30
- compressionRatio: number;
31
- }
32
-
33
19
  declare interface Operations {
34
20
  sharpenSigma?: number;
35
21
  sharpenThreshold?: number;