温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/bun/FileBlob/image
点击访问原文链接

FileBlob.image method | Bun module | Bun

FileBlob.image method | Bun module | BunBuildDocsReferenceGuidesBlogDiscord/Bun/FileBlob/imageMimage

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Bun/FileBlob/imageMimage

method

FileBlob.imageimage(options?: ConstructorOptions): Image;

Wrap this blob in a Bun.Image pipeline. Equivalent to new Bun.Image(this, options) — the constructor is synchronous (the underlying read happens lazily when an Image terminal is awaited), so this works on Bun.file(), Bun.s3(), fd-backed and in-memory blobs alike:

await Bun.file("photo.jpg").image().resize(400).webp().write("thumb.webp");
Referenced typesinterface ConstructorOptionsautoOrient?: boolean

Apply EXIF Orientation (JPEG) before any other operation.

maxPixels?: number

Reject inputs whose width × height exceeds this many pixels. The check runs after the header is read but before any pixel buffer is allocated, so a tiny file claiming a huge canvas is refused cheaply.

namespace Imageinterface ConstructorOptionsautoOrient?: boolean

Apply EXIF Orientation (JPEG) before any other operation.

maxPixels?: number

Reject inputs whose width × height exceeds this many pixels. The check runs after the header is read but before any pixel buffer is allocated, so a tiny file claiming a huge canvas is refused cheaply.

interface Metadataformat: Formatheight: numberwidth: numberinterface ModulateOptionsbrightness?: number

Multiplier; 1 leaves brightness unchanged.

1` = more saturated." data-algolia-static="false" data-algolia-merged="false" data-type="Property">saturation?: number

0 = greyscale, 1 = unchanged, >1 = more saturated.

interface ResizeOptionsfilter?: Filter

Resampling kernel.

fit?: 'fill' | 'inside'

"fill" stretches to exactly width×height. "inside" preserves aspect ratio so the result fits within width×height.

withoutEnlargement?: boolean

Never upscale — if the source is already smaller, leave it.

type ErrorCode = 'ERR_IMAGE_FORMAT_UNSUPPORTED' | 'ERR_IMAGE_TOO_MANY_PIXELS' | 'ERR_IMAGE_DECODE_FAILED' | 'ERR_IMAGE_ENCODE_FAILED' | 'ERR_IMAGE_UNKNOWN_FORMAT' | 'ERR_INVALID_STATE'

Stable error.code values set on rejections from Bun.Image terminals. Branch on these instead of parsing the message.

ERR_IMAGE_FORMAT_UNSUPPORTED — the requested format isn't available on this machine (HEIC/AVIF without the OS codec, TIFF on Linux). Catch this to fall back to a portable format.ERR_IMAGE_TOO_MANY_PIXELS — header dimensions or resize output exceed maxPixels, or a path-backed input is over the 256 MiB cap.ERR_IMAGE_DECODE_FAILED / ERR_IMAGE_ENCODE_FAILED — codec error.ERR_IMAGE_UNKNOWN_FORMAT — input bytes didn't match any sniffer.ERR_INVALID_STATE — the input ArrayBuffer was transferred between construction and the terminal call.File-backed inputs surface the underlying syscall code (ENOENT, EACCES, …) directly.
type Filter = 'nearest' | 'box' | 'bilinear' | 'linear' | 'cubic' | 'mitchell' | 'lanczos2' | 'lanczos3' | 'mks2013' | 'mks2021'type Format = 'jpeg' | 'png' | 'webp' | 'heic' | 'avif' | 'bmp' | 'tiff' | 'gif'

bmp/tiff/gif are decode-only — metadata().format may report them but there are no .bmp()/.tiff()/.gif() encoder methods. tiff decode rejects with error.code === "ERR_IMAGE_FORMAT_UNSUPPORTED" on Linux; gif decodes the first frame everywhere.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

FileBlob.image method | Bun module | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for method bun.FileBlob.image | Bun