extractJpegMetadataSegments
Extracts the metadata segments of a JPEG.
Returns each matching segment whole — marker, length and payload — so injectJpegMetadataSegments can splice it into another JPEG untouched. Only the segments that carry metadata are returned: the EXIF and XMP APP1s and the ICC profile APP2. APP0 (JFIF) is deliberately left behind, because the re-encoded JPEG writes its own.
Returns an empty array for anything that is not a JPEG, including a truncated or malformed one — a caller that cannot preserve metadata should carry on without it rather than fail.
Import:
import { extractJpegMetadataSegments } from 'obsidian-dev-utils/jpeg-metadata';Signature:
function extractJpegMetadataSegments(bytes: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>[]Parameters:
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | The bytes of the source image. |
Returns: Uint8Array<ArrayBufferLike>[] — The metadata segments, in the order they appeared.
Links to this page: