injectJpegMetadataSegments
Splices metadata segments into a JPEG.
The segments go directly after the SOI and the re-encoded JPEG’s own APP0, which is where a reader expects to find them.
Every copied EXIF block has its orientation tag reset to upright. The canvas decode already applied the original orientation to the pixels, so carrying the tag across verbatim would rotate the image a second time — the one piece of metadata that is wrong to preserve as-is.
Import:
import { injectJpegMetadataSegments } from 'obsidian-dev-utils/jpeg-metadata';Signature:
function injectJpegMetadataSegments(jpegBytes: Uint8Array<ArrayBufferLike>, segments: readonly Uint8Array<ArrayBufferLike>[]): Uint8Array<ArrayBufferLike>Parameters:
| Parameter | Type | Description |
|---|---|---|
jpegBytes | Uint8Array<ArrayBufferLike> | The bytes of the re-encoded JPEG. |
segments | readonly Uint8Array<ArrayBufferLike>[] | The segments returned by extractJpegMetadataSegments. |
Returns: Uint8Array<ArrayBufferLike> — The JPEG with the segments spliced in, or the input unchanged when there is nothing to add or the input is not a JPEG.
Links to this page: