From 74191f92bb3622a1330b38ba0a95c2b23abf6c35 Mon Sep 17 00:00:00 2001 From: "A. Molzer" <5550310+197g@users.noreply.github.com> Date: Wed, 14 Jan 2026 18:58:19 +0100 Subject: [PATCH] Change EXIF Applicability's `None` to passthrough This allows it to address the case of copying all EXIF data into a separate file. And as soon as our decoder can handle files without any image data (missing any stripoffsets, etc.) in ways that do not return errors we can hopefully do the opposite and merge the data again. --- src/encoder/mod.rs | 8 ++++++++ src/encoder/tag_filter.rs | 10 ++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs index 9f4ec28..09bd61e 100644 --- a/src/encoder/mod.rs +++ b/src/encoder/mod.rs @@ -777,7 +777,15 @@ impl Default for EncodeMetadataOptions<'_> { #[non_exhaustive] #[derive(Clone, Copy, Default)] pub struct EncodeMetadataApplicability { + /// The photometric interpretation of the image data. + /// + /// If `None` then metadata tags are not filtered, otherwise only tags applicable to the given + /// photometric interpretation are recorded. pub photometric: Option, + /// The planar configuration of the image data. + /// + /// If `None` then metadata tags are not filtered, otherwise only tags applicable to the given + /// configuration are recorded. pub planar: Option, } diff --git a/src/encoder/tag_filter.rs b/src/encoder/tag_filter.rs index 5b7ffef..cc3cc90 100644 --- a/src/encoder/tag_filter.rs +++ b/src/encoder/tag_filter.rs @@ -169,16 +169,10 @@ impl TagFilter { Level::Photometric(photometric) => { match (photometric, target.planar, target.photometric) { (Photometric::All, _, _) => Choice::Ok, - (Photometric::Planar, Some(PlanarConfiguration::Planar), _) => Choice::Ok, - (Photometric::Planar, None, _) - if matches!(self.filter_level, FilterLevel::All) => - { + (Photometric::Planar, Some(PlanarConfiguration::Planar) | None, _) => { Choice::Ok } - (Photometric::YCbCr, _, Some(PhotometricInterpretation::YCbCr)) => Choice::Ok, - (Photometric::YCbCr, _, None) - if matches!(self.filter_level, FilterLevel::All) => - { + (Photometric::YCbCr, _, Some(PhotometricInterpretation::YCbCr) | None) => { Choice::Ok } _ => Choice::Discard,