basalt / storage/src / ImagePipeline
Class: ImagePipeline
Defined in: storage/src/image.ts:67
Fluent, engine-agnostic image pipeline. Steps are collected lazily and run only when a terminal (toBuffer / save / metadata) is awaited:
await disk.image('avatars/1.png').resize(256, 256).webp(80).save('avatars/1.webp')
const meta = await disk.image('hero.jpg').metadata()Constructors
Constructor
> new ImagePipeline(source, processor, saver?): ImagePipeline
Defined in: storage/src/image.ts:70
Parameters
source
() => Promise<Buffer<ArrayBufferLike>>
processor
ImageProcessor | undefined
saver?
(path, content, options?) => Promise<void>
Present only for disk-backed pipelines; enables save().
Returns
ImagePipeline
Accessors
pipeline
Get Signature
> get pipeline(): readonly ImageOp[]
Defined in: storage/src/image.ts:156
The queued operations — for introspection and testing.
Returns
readonly ImageOp[]
Methods
avif()
> avif(quality?): this
Defined in: storage/src/image.ts:121
Parameters
quality?
number
Returns
this
blur()
> blur(sigma?): this
Defined in: storage/src/image.ts:92
Parameters
sigma?
number
Returns
this
flip()
> flip(): this
Defined in: storage/src/image.ts:102
Returns
this
flop()
> flop(): this
Defined in: storage/src/image.ts:107
Returns
this
format()
> format(format, quality?): this
Defined in: storage/src/image.ts:126
Sets the output encoding (and optional quality).
Parameters
format
quality?
number
Returns
this
grayscale()
> grayscale(): this
Defined in: storage/src/image.ts:97
Returns
this
jpeg()
> jpeg(quality?): this
Defined in: storage/src/image.ts:115
Parameters
quality?
number
Returns
this
metadata()
> metadata(): Promise<ImageMetadata>
Defined in: storage/src/image.ts:137
Reads source metadata without applying the queued ops.
Returns
Promise<ImageMetadata>
png()
> png(quality?): this
Defined in: storage/src/image.ts:118
Parameters
quality?
number
Returns
this
resize()
> resize(width?, height?, options?): this
Defined in: storage/src/image.ts:77
Parameters
width?
number
height?
number
options?
Omit<ResizeOptions, "width" | "height"> = {}
Returns
this
rotate()
> rotate(degrees?): this
Defined in: storage/src/image.ts:87
Parameters
degrees?
number
Returns
this
save()
> save(path, options?): Promise<void>
Defined in: storage/src/image.ts:146
Runs the pipeline and writes the result back to the disk (tenant scope, key guard and upload limits all apply, since this delegates to disk.put). The content type is inferred from the last format op unless overridden.
Parameters
path
string
options?
PutOptions = {}
Returns
Promise<void>
toBuffer()
> toBuffer(): Promise<Buffer<ArrayBufferLike>>
Defined in: storage/src/image.ts:132
Runs the pipeline and returns the encoded bytes.
Returns
Promise<Buffer<ArrayBufferLike>>
webp()
> webp(quality?): this
Defined in: storage/src/image.ts:112
Parameters
quality?
number
Returns
this