Skip to main content

edgefirst_codec/
options.rs

1// SPDX-FileCopyrightText: Copyright 2026 Au-Zone Technologies
2// SPDX-License-Identifier: Apache-2.0
3
4//! Output metadata returned by the decoder.
5//!
6//! The codec has no decode options: it always decodes to the source's native
7//! format (JPEG → NV12/GREY, PNG → RGB/RGBA/GREY), writes that format onto the
8//! destination tensor, and reports EXIF orientation for the caller to apply via
9//! `ImageProcessor::convert()`. It never colour-converts or rotates.
10
11use edgefirst_tensor::PixelFormat;
12
13/// Metadata returned after a successful image decode.
14#[derive(Debug, Clone, Copy)]
15pub struct ImageInfo {
16    /// Width of the decoded image in pixels (the source's true width; the
17    /// codec does not apply EXIF rotation).
18    pub width: usize,
19    /// Height of the decoded image in pixels (the source's true height).
20    pub height: usize,
21    /// Native pixel format written to the tensor (JPEG → `Nv12`/`Grey`,
22    /// PNG → `Rgb`/`Rgba`/`Grey`).
23    pub format: PixelFormat,
24    /// Row stride in bytes used when writing into the tensor.
25    pub row_stride: usize,
26    /// EXIF orientation: clockwise rotation in degrees (0/90/180/270) the
27    /// consumer should apply downstream (e.g. via `convert()`). The codec does
28    /// **not** rotate. `0` when there is no EXIF orientation.
29    pub rotation_degrees: u16,
30    /// EXIF horizontal flip the consumer should apply downstream. `false` when
31    /// there is no EXIF orientation.
32    pub flip_horizontal: bool,
33}