New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@imgly/background-removal

Package Overview
Dependencies
Maintainers
8
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@imgly/background-removal - npm Package Compare versions

Comparing version 1.1.5 to 1.2.0

46

dist/index.d.ts

@@ -5,3 +5,3 @@ declare module '@imgly/background-removal/src/codecs' {

function imageDecode(blob: Blob): Promise<NdArray<Uint8Array>>;
function imageEncode(imageTensor: NdArray<Uint8Array>, quality?: number, type?: string): Promise<Blob>;
function imageEncode(imageTensor: NdArray<Uint8Array>, quality?: number, format?: string): Promise<Blob>;

@@ -12,5 +12,6 @@ }

export type { ImageSource, Config };
export { removeBackground };
export { removeBackground, preload };
import { Config } from '@imgly/background-removal/src/schema';
type ImageSource = ImageData | ArrayBuffer | Uint8Array | Blob | URL | string;
function preload(configuration?: Config): Promise<void>;
function removeBackground(image: ImageSource, configuration?: Config): Promise<Blob>;

@@ -28,5 +29,10 @@

proxyToWorker?: boolean;
fetchArgs?: {};
fetchArgs?: any;
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => undefined;
model?: "small" | "medium";
output?: {
format?: "image/png" | "image/jpeg" | "image/webp";
quality?: number;
type?: "background" | "mask" | "foreground";
};
};

@@ -48,4 +54,5 @@ session: import("onnxruntime-common").InferenceSession;

declare module '@imgly/background-removal/src/resource' {
export { loadAsBlob, loadAsUrl };
export { loadAsBlob, loadAsUrl, preload };
import { Config } from '@imgly/background-removal/src/schema';
function preload(config: Config): Promise<void>;
function loadAsUrl(url: string, config: Config): Promise<string>;

@@ -62,5 +69,18 @@ function loadAsBlob(key: string, config: Config): Promise<Blob>;

proxyToWorker: z.ZodDefault<z.ZodBoolean>;
fetchArgs: z.ZodDefault<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
fetchArgs: z.ZodDefault<z.ZodAny>;
progress: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodNumber, z.ZodNumber], z.ZodUnknown>, z.ZodUndefined>>;
model: z.ZodDefault<z.ZodEnum<["small", "medium"]>>;
output: z.ZodDefault<z.ZodObject<{
format: z.ZodDefault<z.ZodEnum<["image/png", "image/jpeg", "image/webp"]>>;
quality: z.ZodDefault<z.ZodNumber>;
type: z.ZodDefault<z.ZodEnum<["foreground", "background", "mask"]>>;
}, "strip", z.ZodTypeAny, {
format?: "image/png" | "image/jpeg" | "image/webp";
quality?: number;
type?: "background" | "mask" | "foreground";
}, {
format?: "image/png" | "image/jpeg" | "image/webp";
quality?: number;
type?: "background" | "mask" | "foreground";
}>>;
}, "strip", z.ZodTypeAny, {

@@ -70,5 +90,10 @@ publicPath?: string;

proxyToWorker?: boolean;
fetchArgs?: {};
fetchArgs?: any;
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => undefined;
model?: "small" | "medium";
output?: {
format?: "image/png" | "image/jpeg" | "image/webp";
quality?: number;
type?: "background" | "mask" | "foreground";
};
}, {

@@ -78,8 +103,13 @@ publicPath?: string;

proxyToWorker?: boolean;
fetchArgs?: {};
fetchArgs?: any;
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => undefined;
model?: "small" | "medium";
output?: {
format?: "image/png" | "image/jpeg" | "image/webp";
quality?: number;
type?: "background" | "mask" | "foreground";
};
}>>;
type Config = z.infer<typeof ConfigSchema>;
function validateConfig(config?: Config): Config;
function validateConfig(configuration?: Config): Config;

@@ -86,0 +116,0 @@ }

12

package.json
{
"name": "@imgly/background-removal",
"version": "1.1.5",
"version": "1.2.0",
"description": "Background Removal in the Browser",

@@ -54,5 +54,3 @@ "keywords": [

"dependencies": {
"onnxruntime-web": "^1.16.0"
},
"devDependencies": {
"onnxruntime-web": "^1.16.0",
"@types/lodash": "^4.14.195",

@@ -62,3 +60,5 @@ "@types/node": "^20.3.1",

"ndarray": "^1.0.19",
"zod": "^3.21.4",
"zod": "^3.21.4"
},
"devDependencies": {
"assert": "^2.0.0",

@@ -76,2 +76,2 @@ "esbuild": "^0.18.18",

}
}
}

@@ -12,3 +12,5 @@ # Background Removal in the Browser

- **`June 28th, 2023`:** We released the code of Background Removal JS.
- **`November 6th, 2023`:** Added support `foreground`, `background` and `mask` export type
- **`November 6th, 2023`:** Added support for `webp` and `jpeg` export formats.
- **`June 28th, 2023`:** We released the code of Background Removal JS for Web.

@@ -64,2 +66,7 @@ ## Overview

model: 'small' | 'medium'; // The model to use. (Default "medium")
output: {
format: 'image/png' | 'image/jpeg' | 'image/webp'; // The output format. (Default "image/png")
quality: number; // The quality. (Default: 0.8)
type: 'foreground' | 'background' | 'mask'; // The output type. (Default "foreground")
};
};

@@ -75,2 +82,16 @@ ```

### Preloading Assets
Per default, assets are downloaded on demand. You might enforce downloading all assets at once at any time by preloading them:
```typescript
import removeBackground, { preload, Config } from '@imgly/background-removal';
const config: Configuration = ...;
preload(config).then(() => {
console.log("Asset preloading succeeded")
})
```
### Download Progress Monitoring

@@ -102,4 +123,3 @@

```shell
cp node_modules/@imgly/background-removal/dist/*.wasm $PUBLIC_PATH
cp node_modules/@imgly/background-removal/dist/*.onnx $PUBLIC_PATH
cp node_modules/@imgly/background-removal/dist/* $PUBLIC_PATH
```

@@ -147,2 +167,4 @@

### Fetch Args
`fetchArgs` are passed as second parameters to the fetch function as described in [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).

@@ -149,0 +171,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc