Skip to content

Latest commit

 

History

History
1140 lines (675 loc) · 31.4 KB

core_src.md

File metadata and controls

1140 lines (675 loc) · 31.4 KB

imagetools / Modules / core/src

Module: core/src

Table of contents

Interfaces

Type Aliases

Variables

Functions

Type Aliases

FitValue

Ƭ FitValue: typeof fitValues[number]

Defined in

packages/core/src/transforms/fit.ts:6


FormatValue

Ƭ FormatValue: typeof formatValues[number]

Defined in

packages/core/src/transforms/format.ts:10


ImageConfig

Ƭ ImageConfig: Record<string, string | string[]>

Defined in

packages/core/src/types.ts:37


ImageTransformation

Ƭ ImageTransformation: (image: Sharp) => Sharp | Promise<Sharp>

Type declaration

▸ (image): Sharp | Promise<Sharp>

Parameters
Name Type
image Sharp
Returns

Sharp | Promise<Sharp>

Defined in

packages/core/src/types.ts:61


KernelValue

Ƭ KernelValue: typeof kernelValues[number]

Defined in

packages/core/src/transforms/kernel.ts:6


OutputFormat

Ƭ OutputFormat: (args?: string[]) => (metadata: ProcessedImageMetadata[]) => unknown

Type declaration

▸ (args?): (metadata: ProcessedImageMetadata[]) => unknown

The JS object returned by the image import.

Parameters
Name Type
args? string[]
Returns

fn

▸ (metadata): unknown

Parameters
Name Type
metadata ProcessedImageMetadata[]
Returns

unknown

Defined in

packages/core/src/types.ts:71


PositionValue

Ƭ PositionValue: typeof positionValues[number]

Defined in

packages/core/src/transforms/position.ts:38


TransformFactory

Ƭ TransformFactory<A>: (metadata: Partial<ImageConfig & A>, ctx: TransformFactoryContext) => ImageTransformation | undefined

Type parameters

Name Type
A Record<string, unknown>

Type declaration

▸ (metadata, ctx): ImageTransformation | undefined

Parameters
Name Type
metadata Partial<ImageConfig & A>
ctx TransformFactoryContext
Returns

ImageTransformation | undefined

Defined in

packages/core/src/types.ts:51


TransformOption

Ƭ TransformOption<A, T>: (metadata: Partial<ImageConfig & A>, image: Sharp) => T | undefined

Type parameters

Name Type
A Record<string, unknown>
T unknown

Type declaration

▸ (metadata, image): T | undefined

Parameters
Name Type
metadata Partial<ImageConfig & A>
image Sharp
Returns

T | undefined

Defined in

packages/core/src/types.ts:56

Variables

builtinOutputFormats

Const builtinOutputFormats: Object

Type declaration

Name Type
img OutputFormat
meta OutputFormat
metadata OutputFormat
picture OutputFormat
srcset OutputFormat
url OutputFormat

Defined in

packages/core/src/output-formats.ts:112


builtins

Const builtins: (TransformFactory<BlurOptions> | TransformFactory<FlattenOptions> | TransformFactory<FlipOptions> | TransformFactory<FlopOptions> | TransformFactory<FormatOptions> | TransformFactory<GrayscaleOptions> | TransformFactory<HSBOptions> | TransformFactory<InvertOptions> | TransformFactory<MedianOptions> | TransformFactory<NormalizeOptions> | TransformFactory<ResizeOptions> | TransformFactory<RotateOptions> | TransformFactory<TintOptions>)[]

Defined in

packages/core/src/builtins.ts:15


fitValues

Const fitValues: readonly ["cover", "contain", "fill", "inside", "outside"]

Defined in

packages/core/src/transforms/fit.ts:4


formatValues

Const formatValues: readonly ["avif", "jpg", "jpeg", "png", "heif", "webp", "tiff"]

Defined in

packages/core/src/transforms/format.ts:8


kernelValues

Const kernelValues: readonly ["nearest", "cubic", "mitchell", "lanczos2", "lanczos3"]

Defined in

packages/core/src/transforms/kernel.ts:4


positionShorthands

Const positionShorthands: string[]

Defined in

packages/core/src/transforms/position.ts:27


positionValues

Const positionValues: readonly ["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest", "center", "centre", "entropy", "attention"]

Defined in

packages/core/src/transforms/position.ts:4

Functions

applyTransforms

applyTransforms(transforms, image, removeMetadata?): Promise<TransformResult>

Parameters

Name Type Default value
transforms ImageTransformation[] undefined
image Sharp undefined
removeMetadata boolean true

Returns

Promise<TransformResult>

Defined in

packages/core/src/lib/apply-transforms.ts:5


blur

blur(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & BlurOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


extractEntries

extractEntries(searchParams): [string, string[]][]

Parameters

Name Type
searchParams URLSearchParams

Returns

[string, string[]][]

Defined in

packages/core/src/lib/parse-url.ts:5


flatten

flatten(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & FlattenOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


flip

flip(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & FlipOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


flop

flop(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & FlopOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


format

format(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & FormatOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


generateImageID

generateImageID(url, config): string

Parameters

Name Type
url URL
config ImageConfig

Returns

string

Defined in

packages/core/src/util.ts:10


generateTransforms

generateTransforms(config, factories, manualSearchParams, logger?): Object

Parameters

Name Type
config ImageConfig
factories TransformFactory[]
manualSearchParams URLSearchParams
logger? Logger

Returns

Object

Name Type
parametersUsed Set<string>
transforms ImageTransformation[]

Defined in

packages/core/src/lib/generate-transforms.ts:4


getBackground

getBackground(metadata, image): undefined | string

Parameters

Name Type
metadata Partial<ImageConfig & BackgroundOptions>
image Sharp

Returns

undefined | string

Defined in

packages/core/src/types.ts:56


getFit

getFit(metadata, image): undefined | "cover" | "contain" | "fill" | "inside" | "outside"

Parameters

Name Type
metadata Partial<ImageConfig & FitOptions>
image Sharp

Returns

undefined | "cover" | "contain" | "fill" | "inside" | "outside"

Defined in

packages/core/src/types.ts:56


getKernel

getKernel(metadata, image): undefined | "nearest" | "cubic" | "mitchell" | "lanczos2" | "lanczos3"

Parameters

Name Type
metadata Partial<ImageConfig & KernelOptions>
image Sharp

Returns

undefined | "nearest" | "cubic" | "mitchell" | "lanczos2" | "lanczos3"

Defined in

packages/core/src/types.ts:56


getLossless

getLossless(metadata, image): unknown

Parameters

Name Type
metadata Partial<ImageConfig & LosslessOptions>
image Sharp

Returns

unknown

Defined in

packages/core/src/types.ts:56


getMetadata

getMetadata(image, key): unknown

Parameters

Name Type
image Sharp
key string

Returns

unknown

Defined in

packages/core/src/lib/metadata.ts:16


getPosition

getPosition(metadata, image): undefined | "top" | "right top" | "right" | "right bottom" | "bottom" | "left bottom" | "left" | "left top" | "north" | "northeast" | "east" | "southeast" | "south" | "southwest" | "west" | "northwest" | "center" | "centre" | "entropy" | "attention"

Parameters

Name Type
metadata Partial<ImageConfig & PositionOptions>
image Sharp

Returns

undefined | "top" | "right top" | "right" | "right bottom" | "bottom" | "left bottom" | "left" | "left top" | "north" | "northeast" | "east" | "southeast" | "south" | "southwest" | "west" | "northwest" | "center" | "centre" | "entropy" | "attention"

Defined in

packages/core/src/types.ts:56


getProgressive

getProgressive(metadata, image): unknown

Parameters

Name Type
metadata Partial<ImageConfig & ProgressiveOptions>
image Sharp

Returns

unknown

Defined in

packages/core/src/types.ts:56


getQuality

getQuality(metadata, image): undefined | number

Parameters

Name Type
metadata Partial<ImageConfig & QualityOptions>
image Sharp

Returns

undefined | number

Defined in

packages/core/src/types.ts:56


grayscale

grayscale(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & GrayscaleOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


hsb

hsb(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & HSBOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


imgFormat

imgFormat(args?): (metadata: ProcessedImageMetadata[]) => unknown

The JS object returned by the image import.

Parameters

Name Type
args? string[]

Returns

fn

▸ (metadata): unknown

Parameters
Name Type
metadata ProcessedImageMetadata[]
Returns

unknown

Defined in

packages/core/src/types.ts:71


invert

invert(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & InvertOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


loadImage

loadImage(path): Sharp

Parameters

Name Type
path string

Returns

Sharp

Defined in

packages/core/src/util.ts:6


median

median(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & MedianOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


metadataFormat

metadataFormat(args?): (metadata: ProcessedImageMetadata[]) => unknown

The JS object returned by the image import.

Parameters

Name Type
args? string[]

Returns

fn

▸ (metadata): unknown

Parameters
Name Type
metadata ProcessedImageMetadata[]
Returns

unknown

Defined in

packages/core/src/types.ts:71


normalize

normalize(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & NormalizeOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


parseURL

parseURL(rawURL): URL

Parameters

Name Type
rawURL string

Returns

URL

Defined in

packages/core/src/lib/parse-url.ts:1


pictureFormat

pictureFormat(args?): (metadata: ProcessedImageMetadata[]) => unknown

fallback format should be specified last

Parameters

Name Type
args? string[]

Returns

fn

▸ (metadata): unknown

Parameters
Name Type
metadata ProcessedImageMetadata[]
Returns

unknown

Defined in

packages/core/src/types.ts:71


resize

resize(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & ResizeOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


resolveConfigs

resolveConfigs(entries, outputFormats): Record<string, string | string[]>[]

This function builds up all possible combinations the given entries can be combined and returns it as an array of objects that can be given to a the transforms.

Parameters

Name Type Description
entries [string, string[]][] The url parameter entries
outputFormats Record<string, OutputFormat> -

Returns

Record<string, string | string[]>[]

An array of directive options

Defined in

packages/core/src/lib/resolve-configs.ts:17


rotate

rotate(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & RotateOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


setMetadata

setMetadata(image, key, value): void

Parameters

Name Type
image Sharp
key string
value unknown

Returns

void

Defined in

packages/core/src/lib/metadata.ts:12


srcsetFormat

srcsetFormat(args?): (metadata: ProcessedImageMetadata[]) => unknown

The JS object returned by the image import.

Parameters

Name Type
args? string[]

Returns

fn

▸ (metadata): unknown

Parameters
Name Type
metadata ProcessedImageMetadata[]
Returns

unknown

Defined in

packages/core/src/types.ts:71


tint

tint(metadata, ctx): undefined | ImageTransformation

Parameters

Name Type
metadata Partial<ImageConfig & TintOptions>
ctx TransformFactoryContext

Returns

undefined | ImageTransformation

Defined in

packages/core/src/types.ts:51


urlFormat

urlFormat(args?): (metadata: ProcessedImageMetadata[]) => unknown

The JS object returned by the image import.

Parameters

Name Type
args? string[]

Returns

fn

▸ (metadata): unknown

Parameters
Name Type
metadata ProcessedImageMetadata[]
Returns

unknown

Defined in

packages/core/src/types.ts:71