Skip to content

blobToJpegArrayBuffer

Converts a Blob object to a JPEG ArrayBuffer with the specified quality.

The conversion is a canvas re-encode, which keeps only the pixels — EXIF, GPS, XMP and the ICC profile are dropped by construction. Pass BlobToJpegArrayBufferOptions.shouldPreserveMetadata to carry those segments across from the source, which works only when the source is itself a JPEG: nothing else stores them in a form that can be copied verbatim.

Import:

import { blobToJpegArrayBuffer } from 'obsidian-dev-utils/blob';

Signature:

function blobToJpegArrayBuffer(blob: Blob, jpegQuality: number, options: BlobToJpegArrayBufferOptions | undefined): Promise<ArrayBuffer>

Parameters:

ParameterTypeDescription
blobBlobThe Blob object to convert.
jpegQualitynumberThe quality of the JPEG image (0 to 1).
optionsBlobToJpegArrayBufferOptions | undefinedConversion options.

Returns: Promise<ArrayBuffer> — A Promise that resolves to an ArrayBuffer.


Links to this page: