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.4.0 to 1.4.1

dist/codecs.d.ts

6

CHANGELOG.md

@@ -7,2 +7,8 @@ # Changelog

## [Unreleased]
### Changed
- Typescript bindings are generated with tsc
## [1.4.0]

@@ -9,0 +15,0 @@

194

dist/index.d.ts

@@ -1,162 +0,32 @@

declare module '@imgly/background-removal/codecs' {
export { imageEncode, imageDecode, MimeType };
import { NdArray } from 'ndarray';
function imageDecode(blob: Blob): Promise<NdArray<Uint8Array>>;
function imageEncode(imageTensor: NdArray<Uint8Array>, quality?: number, format?: string): Promise<Blob>;
class MimeType {
type: string;
params: Record<string, string>;
private constructor();
toString(): string;
static create(type: any, params: Record<string, string>): MimeType;
isIdentical(other: MimeType): Boolean;
isEqual(other: MimeType): Boolean;
static fromString(mimeType: string): MimeType;
}
}
declare module '@imgly/background-removal/index' {
export default removeBackground;
export { preload, removeBackground, removeForeground, segmentForeground, applySegmentationMask };
export type { Config, ImageSource };
import { Config } from '@imgly/background-removal/schema';
import { ImageSource } from '@imgly/background-removal/utils';
function preload(configuration?: Config): Promise<void>;
/**
* Removes the background from an image.
*
* @param image - The image to remove the background from.
* @param configuration - Optional configuration for the background removal process.
* @returns A Promise that resolves to the resulting image with the background removed.
*/
function removeBackground(image: ImageSource, configuration?: Config): Promise<Blob>;
/**
* Removes the foreground from an image.
*
* @param image - The image to remove the foreground from.
* @param configuration - Optional configuration for the foreground removal process.
* @returns A Promise that resolves to the resulting image with the foreground removed.
*/
function removeForeground(image: ImageSource, configuration?: Config): Promise<Blob>;
/**
* Segments the foreground of an image using a given configuration.
*
* @param image - The image source to segment.
* @param configuration - The optional configuration for the segmentation.
* @returns A Promise that resolves to the segmented foreground as a Blob.
*/
function segmentForeground(image: ImageSource, configuration?: Config): Promise<Blob>;
function applySegmentationMask(image: any, mask: any, config?: Config): Promise<Blob>;
}
declare module '@imgly/background-removal/inference' {
export { initInference, runInference };
import { Config } from '@imgly/background-removal/schema';
import { NdArray } from 'ndarray';
function initInference(config?: Config): Promise<{
config: {
publicPath?: string;
debug?: boolean;
proxyToWorker?: boolean;
fetchArgs?: any;
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => void;
model?: "small" | "medium";
output?: {
format?: "image/png" | "image/jpeg" | "image/webp" | "image/x-rgba8" | "image/x-alpha8";
quality?: number;
};
};
session: import("onnxruntime-common").InferenceSession;
}>;
function runInference(imageTensor: NdArray<Uint8Array>, config: Config, session: any): Promise<NdArray<Uint8Array>>;
}
declare module '@imgly/background-removal/onnx' {
export { createOnnxSession, runOnnxSession };
import { NdArray } from 'ndarray';
import * as ort from 'onnxruntime-web';
import { Config } from '@imgly/background-removal/schema';
function createOnnxSession(model: any, config: Config): Promise<ort.InferenceSession>;
function runOnnxSession(session: any, inputs: [string, NdArray<Float32Array>][], outputs: [string]): Promise<NdArray<Float32Array>[]>;
}
declare module '@imgly/background-removal/resource' {
export { loadAsBlob, loadAsUrl, preload };
import { Config } from '@imgly/background-removal/schema';
function preload(config: Config): Promise<void>;
function loadAsUrl(url: string, config: Config): Promise<string>;
function loadAsBlob(key: string, config: Config): Promise<Blob>;
}
declare module '@imgly/background-removal/schema' {
export { Config, ConfigSchema, validateConfig };
import { z } from 'zod';
const ConfigSchema: z.ZodDefault<z.ZodObject<{
publicPath: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, string, string>;
debug: z.ZodDefault<z.ZodBoolean>;
proxyToWorker: z.ZodDefault<z.ZodBoolean>;
fetchArgs: z.ZodDefault<z.ZodAny>;
progress: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodNumber, z.ZodNumber], z.ZodUnknown>, z.ZodVoid>>;
model: z.ZodDefault<z.ZodEnum<["small", "medium"]>>;
output: z.ZodDefault<z.ZodObject<{
format: z.ZodDefault<z.ZodEnum<["image/png", "image/jpeg", "image/webp", "image/x-rgba8", "image/x-alpha8"]>>;
quality: z.ZodDefault<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
format?: "image/png" | "image/jpeg" | "image/webp" | "image/x-rgba8" | "image/x-alpha8";
quality?: number;
}, {
format?: "image/png" | "image/jpeg" | "image/webp" | "image/x-rgba8" | "image/x-alpha8";
quality?: number;
}>>;
}, "strip", z.ZodTypeAny, {
publicPath?: string;
debug?: boolean;
proxyToWorker?: boolean;
fetchArgs?: any;
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => void;
model?: "small" | "medium";
output?: {
format?: "image/png" | "image/jpeg" | "image/webp" | "image/x-rgba8" | "image/x-alpha8";
quality?: number;
};
}, {
publicPath?: string;
debug?: boolean;
proxyToWorker?: boolean;
fetchArgs?: any;
progress?: (args_0: string, args_1: number, args_2: number, ...args_3: unknown[]) => void;
model?: "small" | "medium";
output?: {
format?: "image/png" | "image/jpeg" | "image/webp" | "image/x-rgba8" | "image/x-alpha8";
quality?: number;
};
}>>;
type Config = z.infer<typeof ConfigSchema>;
function validateConfig(configuration?: Config): Config;
}
declare module '@imgly/background-removal/url' {
export { isAbsoluteURI, ensureAbsoluteURI };
function isAbsoluteURI(url: string): boolean;
function ensureAbsoluteURI(url: string, baseUrl: string): string;
}
declare module '@imgly/background-removal/utils' {
export { imageDecode, imageEncode, tensorResizeBilinear, tensorHWCtoBCHW, imageBitmapToImageData, calculateProportionalSize, imageSourceToImageData, ImageSource, createCanvas };
import { NdArray } from 'ndarray';
import { imageDecode, imageEncode } from '@imgly/background-removal/codecs';
import { Config } from '@imgly/background-removal/schema';
type ImageSource = ImageData | ArrayBuffer | Uint8Array | Blob | URL | string;
function imageBitmapToImageData(imageBitmap: ImageBitmap): ImageData;
function tensorResizeBilinear(imageTensor: NdArray<Uint8Array>, newWidth: number, newHeight: number): NdArray<Uint8Array>;
function tensorHWCtoBCHW(imageTensor: NdArray<Uint8Array>, mean?: number[], std?: number[]): NdArray<Float32Array>;
function calculateProportionalSize(originalWidth: number, originalHeight: number, maxWidth: number, maxHeight: number): [number, number];
function imageSourceToImageData(image: ImageSource, config: Config): Promise<NdArray<Uint8Array>>;
export function convertFloat32ToUint8(float32Array: NdArray<Float32Array>): NdArray<Uint8Array>;
function createCanvas(width: any, height: any): any;
}
declare module '@imgly/background-removal' {
import main = require('@imgly/background-removal/src/index');
export = main;
}
export default removeBackground;
export { preload, removeBackground, removeForeground, segmentForeground, applySegmentationMask };
export type { Config, ImageSource };
import { Config } from './schema';
import { ImageSource } from './utils';
declare function preload(configuration?: Config): Promise<void>;
/**
* Removes the background from an image.
*
* @param image - The image to remove the background from.
* @param configuration - Optional configuration for the background removal process.
* @returns A Promise that resolves to the resulting image with the background removed.
*/
declare function removeBackground(image: ImageSource, configuration?: Config): Promise<Blob>;
/**
* Removes the foreground from an image.
*
* @param image - The image to remove the foreground from.
* @param configuration - Optional configuration for the foreground removal process.
* @returns A Promise that resolves to the resulting image with the foreground removed.
*/
declare function removeForeground(image: ImageSource, configuration?: Config): Promise<Blob>;
/**
* Segments the foreground of an image using a given configuration.
*
* @param image - The image source to segment.
* @param configuration - The optional configuration for the segmentation.
* @returns A Promise that resolves to the segmented foreground as a Blob.
*/
declare function segmentForeground(image: ImageSource, configuration?: Config): Promise<Blob>;
declare function applySegmentationMask(image: any, mask: any, config?: Config): Promise<Blob>;
//# sourceMappingURL=index.d.ts.map
{
"name": "@imgly/background-removal",
"version": "1.4.0",
"version": "1.4.1",
"description": "Background Removal in the Browser",

@@ -52,5 +52,8 @@ "keywords": [

"changelog:generate": "node ../../scripts/changelog/changelog-generate.mjs",
"build": "npm run clean && npm run resources && npm run changelog:generate && node scripts/build.mjs",
"build": "npm run clean && npm run types && npm run resources && npm run changelog:generate && node scripts/build.mjs",
"types": " npx tsc --declaration --emitDeclarationOnly --declarationDir dist --declarationMap",
"watch": "npm run clean && npm run resources && npm run changelog:generate && node scripts/watch.mjs",
"publish": "npm run build && npm publish --access public",
"publish:latest": "npm run build && npm publish --tag latest --access public",
"publish:next": "npm run build && npm publish --tag next --access public",
"package:pack": "npm run build && npm pack . --pack-destination ../../releases",
"lint": "npx prettier --write ."

@@ -79,2 +82,2 @@ },

}
}
}

@@ -26,3 +26,3 @@ # Background Removal in the Browser

The Neural Network ([ONNX model](https://onnx.ai/)) and WASM files used by `@imgly/background-removal` are hosted on [UNPKG](https://www.unpkg.com/), making it readily available for download to all users of the library. See the section Custom Asset Serving if you want to host data on your own servers.
The Neural Network ([ONNX model](https://onnx.ai/)) and WASM files used by `@imgly/background-removal` are hosted by [IMG.LY](https://img.ly/) by default. See the section Custom Asset Serving if you want to host them on your own servers.

@@ -60,3 +60,3 @@ ## Installation

type Config = {
publicPath: string; // The public path used for model and wasm files. Default: 'https://unpkg.com/${PACKAGE_NAME}@${PACKAGE_VERSION}/dist/'
publicPath: string; // The public path used for model and wasm files. Default: 'https://staticimgly.com/${PACKAGE_NAME}-data/@${PACKAGE_VERSION}/dist/'
debug: bool; // enable or disable useful console.log outputs

@@ -117,3 +117,3 @@ proxyToWorker: bool; // Whether to proxy the calculations to a web worker. (Default true)

Currently, the wasm and onnx neural networks are served via unpkg. For production use, we advise you to host them yourself. Therefore, copy all .wasm and .onnx files to your public path `$PUBLIC_PATH` and reconfigure the library.
The wasm and onnx neural networks are hosted by IMG.LY by default. For production use, we advise you to host them yourself. Therefore, copy all .wasm and .onnx files to your public path `$PUBLIC_PATH` and reconfigure the library.

@@ -120,0 +120,0 @@ ```shell

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