Media: Targa/HDR stills keep their Exif orientation; DPX test accepts a stated transfer

#755 decoded stills of an extension-decided format with load_from_memory_with_format,
bypassing #827's oriented decode: load_oriented now takes the format.
The DPX ffmpeg oracle test expected the bare codec name; ffmpeg builds that write
the transfer characteristic make it "DPX 8-bit RGB, linear".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-12 03:45:49 -04:00
co-authored by Claude Opus 5.5
parent 42ef79a2fd
commit 6d4e721d2c
4 changed files with 13 additions and 9 deletions
+8 -3
View File
@@ -221,10 +221,15 @@ pub(crate) fn swaps_sides(o: Orientation) -> bool {
/// Decode a still the way it is meant to be seen: its Exif orientation (a camera held sideways, a
/// mirrored scan) is applied to the pixels, as image viewers do. A file without
/// the tag, or with a broken one, decodes as stored.
pub(crate) fn load_oriented(bytes: &[u8]) -> image::ImageResult<image::DynamicImage> {
/// the tag, or with a broken one, decodes as stored. `fmt`: the format when the file's extension
/// decides it (Targa has no signature to guess from), else guessed from the bytes.
pub(crate) fn load_oriented(bytes: &[u8], fmt: Option<image::ImageFormat>) -> image::ImageResult<image::DynamicImage> {
use image::ImageDecoder;
let mut dec = image::ImageReader::new(std::io::Cursor::new(bytes)).with_guessed_format()?.into_decoder()?;
let reader = match fmt {
Some(fmt) => image::ImageReader::with_format(std::io::Cursor::new(bytes), fmt),
None => image::ImageReader::new(std::io::Cursor::new(bytes)).with_guessed_format()?,
};
let mut dec = reader.into_decoder()?;
let orientation = dec.orientation().unwrap_or(Orientation::NoTransforms);
let mut img = image::DynamicImage::from_decoder(dec)?;
img.apply_orientation(orientation);