Classes

Image.mjs

@mr_ozio/scraper-utils · v2.5.0 · Generated April 21, 2026

Target Style

Target Style

1 exports

class

Image

Target Style
export class Image {

No description provided.

Target style API. Preferred for new code.

Members

22 items

Target Style

Target Style

11 members

static method

load

Target Style
static load({ from }) {

/** Loads an image wrapper from a file path.

Parameters

  • options{ from: string }

Returns

Image

method

metadata

Target Style
async metadata() {

/** Returns cached image metadata.

Returns

Promise<import('sharp').Metadata>

method

trim

Target Style
async trim({ threshold = THRESHOLD } = {}) {

/** Trims image borders using a color threshold.

Parameters

  • [options]{ threshold?: number }

Returns

Promise<Image>

method

makeSquare

Target Style
async makeSquare() {

/** Resizes the image to a centered square.

Returns

Promise<Image>

method

hasBorders

Target Style
async hasBorders() {

/** Detects whether the image has solid borders.

Returns

Promise<boolean>

method

perceptualHash

Target Style
async perceptualHash({ complexity = HASH_COMPLEXITY } = {}) {

/** Returns a perceptual hash for the image.

Parameters

  • [options]{ complexity?: number }

Returns

Promise<string>

method

differenceHash

Target Style
async differenceHash({ complexity = HASH_COMPLEXITY } = {}) {

/** Returns a difference hash for the image.

Parameters

  • [options]{ complexity?: number }

Returns

Promise<string>

method

dominantColor

Target Style
async dominantColor() {

/** Returns the dominant image color.

Returns

Promise<{ r: number, g: number, b: number }>

method

averageColor

Target Style
async averageColor() {

/** Returns the average image color.

Returns

Promise<{ r: number, g: number, b: number }>

method

dimensions

Target Style
async dimensions() {

/** Returns current image dimensions.

Returns

Promise<{ width: number, height: number }>

method

aspectRatio

Target Style
async aspectRatio() {

/** Returns the current image aspect ratio.

Returns

Promise<number>

Legacy Style

Legacy Style

11 members

constructor

constructor

Legacy Style
constructor(buffer) {

/** Builds an image wrapper from a file path or raw buffer.

Parameters

  • bufferstring | Buffer

method

getMeta

Legacy Style
async getMeta() {

/** Returns cached image metadata.

Returns

Promise<import('sharp').Metadata>

method

crop

Legacy Style
async crop(threshold = THRESHOLD) {

/** Trims image borders using a color threshold.

Parameters

  • thresholdnumber

Returns

Promise<Image>

method

square

Legacy Style
async square() {

/** Resizes the image to a centered square.

Returns

Promise<Image>

method

getHash

Legacy Style
async getHash(complexity) {

/** Returns a perceptual hash for the image.

Parameters

  • complexitynumber

Returns

Promise<string>

method

getPHash

Legacy Style
async getPHash(complexity = HASH_COMPLEXITY) {

/** Returns a perceptual hash for the image.

Parameters

  • complexitynumber

Returns

Promise<string>

method

getDHash

Legacy Style
async getDHash(complexity = HASH_COMPLEXITY) {

/** Returns a difference hash for the image.

Parameters

  • complexitynumber

Returns

Promise<string>

method

getDominantColor

Legacy Style
async getDominantColor() {

/** Returns the dominant image color.

Returns

Promise<{ r: number, g: number, b: number }>

method

getAverageColor

Legacy Style
async getAverageColor() {

/** Returns the average image color.

Returns

Promise<{ r: number, g: number, b: number }>

method

getDimentions

Legacy Style
async getDimentions() {

/** Returns current image dimensions.

Returns

Promise<{ width: number, height: number }>

method

getRatio

Legacy Style
async getRatio() {

/** Returns the current image aspect ratio.

Returns

Promise<number>

Legacy Style

Legacy Style

0 exports

No legacy exports in this module.