From fee5d444c72b0535741c775ad151767ee3b94bd9 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Tue, 15 Oct 2024 17:14:54 +0100 Subject: [PATCH 1/2] Change orientation doc comment to use .orientation() instead of manual parsing with kamadak-exif --- src/dynimage.rs | 19 +++---------------- src/metadata.rs | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/dynimage.rs b/src/dynimage.rs index 027b932743..273ac03a38 100644 --- a/src/dynimage.rs +++ b/src/dynimage.rs @@ -940,25 +940,12 @@ impl DynamicImage { /// /// ``` /// # fn only_check_if_this_compiles() -> Result<(), Box> { - /// # use image::{Orientation, DynamicImage, ImageReader, ImageDecoder}; - /// use exif::{In, Tag}; // third-party crate `kamadak_exif` is needed to parse Exif chunk + /// use image::{Orientation, DynamicImage, ImageReader, ImageDecoder}; /// /// let mut decoder = ImageReader::open("file.jpg")?.into_decoder()?; - /// let raw_exif = decoder.exif_metadata(); + /// let orientation = decoder.orientation()?; /// let mut image = DynamicImage::from_decoder(decoder)?; - /// - /// // Parse Exif chunk (if present) and apply the orientation - /// if let Ok(Some(raw_exif)) = raw_exif { - /// let reader = exif::Reader::new(); - /// let exif = reader.read_raw(raw_exif)?; - /// if let Some(orientation) = exif.get_field(Tag::Orientation, In::PRIMARY) { - /// if let Some(value) = orientation.value.get_uint(0) { - /// if let Some(orientation) = Orientation::from_exif(value as u8) { - /// image.apply_orientation(orientation); - /// } - /// } - /// } - /// } + /// image.apply_orientation(orientation); /// # Ok(()) /// # } /// ``` diff --git a/src/metadata.rs b/src/metadata.rs index ea33af07eb..01da89bc6c 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -5,7 +5,7 @@ use byteorder_lite::{BigEndian, LittleEndian, ReadBytesExt}; /// Describes the transformations to be applied to the image. /// Compatible with [Exif orientation](https://web.archive.org/web/20200412005226/https://www.impulseadventure.com/photo/exif-orientation.html). /// -/// Orientation is specified in the Exif metadata, and is often written by cameras. +/// Orientation is specified in the file's metadata, and is often written by cameras. /// /// You can apply it to an image via [`DynamicImage::apply_orientation`](crate::DynamicImage::apply_orientation). #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] From e502e48a3f3a1864fddd7c01f5d1fcf570cdebf5 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Tue, 15 Oct 2024 17:15:17 +0100 Subject: [PATCH 2/2] Drop kamadak-exif as a dev-dependency --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index aacf80aee8..c540d148f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,6 @@ num-complex = "0.4" glob = "0.3" quickcheck = "1" criterion = "0.5.0" -kamadak-exif = "0.5.5" [features] default = ["rayon", "default-formats"]