π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
image decoder comment prune
laurenspriemea9df0121c64
diff --git a/rust/crates/image/src/color_management.rs b/rust/crates/image/src/color_management.rsindex 3434f33eba..3a41df4f53 100644--- a/rust/crates/image/src/color_management.rs+++ b/rust/crates/image/src/color_management.rs@@ -132,7 +132,6 @@ where}}-/// Subpixel types for which moxcms can transform pixel buffers to sRGB.trait TransformSubpixel: Copy {fn transform_to_srgb(pixels: &mut [Self],@@ -149,10 +148,8 @@ impl TransformSubpixel for u8 {encoded_profile: &[u8],layout: Layout,) -> Result<Option<Vec<Self>>, String> {- // A2B LUTs take ICC precedence over matrix/TRC, and the in-place- // executor only implements matrix math, so LUT-carrying profiles go- // out-of-place; the matrix path is the fallback when the LUT does- // not cover the default intent (moxcms has no cross-intent fallback).+ // ICC gives A2B LUTs precedence, but moxcms executes them only out of+ // place. Fall back to matrix/TRC without a default Perceptual LUT.if profile_has_device_to_pcs_lut(source_profile)&& let Ok(transformed) = transform_u8_out_of_place(pixels, source_profile, layout){@@ -244,8 +241,6 @@ fn cached_color_profile(encoded: &[u8]) -> Result<Arc<ColorProfile>, String> {Ok(profile)}-/// Cache only exact profile bytes, bound both entry count and profile size,-/// and retain at most one u8 transform per pixel layout in each entry.fn cached_u8_transform(encoded: &[u8],source_profile: &ColorProfile,@@ -508,8 +503,6 @@ mod tests {})}- /// An RGB profile that converts only through an A2B LUT (no TRC tags),- /// like calibrated display/scanner profiles.fn lut_based_rgb_profile() -> ColorProfile {let mut profile = ColorProfile::new_display_p3();profile.red_trc = None;@@ -666,8 +659,6 @@ mod tests {assert_eq!(actual, expected);}- /// A profile with matrix/TRC AND A2B LUT tags must be converted via the- /// LUT (ICC precedence), even though the in-place constructor accepts it.#[test]fn profile_with_matrix_and_lut_tags_is_transformed_via_the_lut() {let mut profile = ColorProfile::new_display_p3();@@ -712,8 +703,6 @@ mod tests {assert_eq!(actual, expected);}- /// A colorimetric-only A2B LUT (no A2B0) is unusable under moxcms's- /// default Perceptual intent; the matrix path must still convert.#[test]fn profile_with_unusable_lut_intent_falls_back_to_the_matrix_transform() {let mut profile = ColorProfile::new_display_p3();diff --git a/rust/crates/image/src/decode.rs b/rust/crates/image/src/decode.rsindex 17719a3568..a3f9389fa0 100644--- a/rust/crates/image/src/decode.rs+++ b/rust/crates/image/src/decode.rs@@ -135,9 +135,8 @@ fn decode_reader_with_image_crate<R>(whereR: BufRead + Seek,{- // HEIF-family readers resolve to ente_heic's lazy hook adapter here. Keep- // the decoder intact until DynamicImage allocates and supplies its output- // buffer so the adapter can decode directly into it.+ // ente_heic decodes lazily into DynamicImage's output buffer, so the+ // decoder must remain intact through `from_decoder`.let mut decoder = reader.into_decoder()?;let icc_profile = match decoder.icc_profile() {Ok(icc_profile) => icc_profile,@@ -461,9 +460,7 @@ fn read_exif_orientation_from_bytes(image_bytes: &[u8]) -> Option<u8> {.filter(|value| (1..=8).contains(value))}-/// JPEG XL must never have an EXIF-derived orientation applied: jxl-oxide-/// already applies the authoritative codestream orientation (ISO/IEC-/// 18181-2), and encoders keep a redundant EXIF tag in the container.+/// jxl-oxide applies codestream orientation; ignore redundant container EXIF.fn bytes_look_like_jxl(image_bytes: &[u8]) -> bool {const BARE_CODESTREAM_SIGNATURE: [u8; 2] = [0xFF, 0x0A];const CONTAINER_SIGNATURE: [u8; 12] = [@@ -622,14 +619,10 @@ mod tests {}fn exif_orientation(orientation: u16) -> Vec<u8> {+ // Little-endian TIFF with one inline SHORT orientation and no next IFD.let mut exif = vec![- b'I', b'I', 42, 0, 8, 0, 0, 0, // Little-endian TIFF header and IFD offset.- 1, 0, // One IFD entry.- 0x12, 0x01, // Orientation tag.- 3, 0, // SHORT.- 1, 0, 0, 0, // One value.- 0, 0, 0, 0, // Inline value, filled below.- 0, 0, 0, 0, // No next IFD.+ b'I', b'I', 42, 0, 8, 0, 0, 0, 1, 0, 0x12, 0x01, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,+ 0,];exif[18..20].copy_from_slice(&orientation.to_le_bytes());exifdiff --git a/rust/crates/image/src/types.rs b/rust/crates/image/src/types.rsindex d2c767129f..cef4bb7e29 100644--- a/rust/crates/image/src/types.rs+++ b/rust/crates/image/src/types.rs@@ -4,14 +4,8 @@ pub struct Dimensions {pub height: u32,}-/// Decoded pixels normalized to this crate's output contract: 8-bit RGB in-/// the sRGB color space, with EXIF orientation applied.-///-/// Embedded ICC profiles are converted to sRGB on a best-effort basis: images-/// without a profile are assumed to already be sRGB, and images whose profile-/// cannot be applied (unparseable data, unsupported layouts, or PQ/HLG-/// transfer curves that would need tone mapping) keep their decoded pixel-/// values.+/// 8-bit sRGB with EXIF orientation applied. ICC conversion is best-effort;+/// absent, unusable, or PQ/HLG profiles leave decoded values unchanged.#[derive(Clone, Debug)]pub struct DecodedImage {pub dimensions: Dimensions,