From fb5799bd8fdfac399c9b40817b62a98dada19a1b Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Tue, 15 Oct 2024 22:24:09 +0100 Subject: [PATCH] Move Orientation to metadata module --- src/codecs/jpeg/decoder.rs | 3 ++- src/codecs/tiff.rs | 2 +- src/codecs/webp/decoder.rs | 5 ++--- src/dynimage.rs | 5 +++-- src/image.rs | 3 ++- src/lib.rs | 3 +-- src/metadata.rs | 2 ++ 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/codecs/jpeg/decoder.rs b/src/codecs/jpeg/decoder.rs index c846f46ec2..7f9cf518ce 100644 --- a/src/codecs/jpeg/decoder.rs +++ b/src/codecs/jpeg/decoder.rs @@ -6,7 +6,8 @@ use crate::error::{ DecodingError, ImageError, ImageResult, LimitError, UnsupportedError, UnsupportedErrorKind, }; use crate::image::{ImageDecoder, ImageFormat}; -use crate::{Limits, Orientation}; +use crate::metadata::Orientation; +use crate::Limits; type ZuneColorSpace = zune_core::colorspace::ColorSpace; diff --git a/src/codecs/tiff.rs b/src/codecs/tiff.rs index 395dc481db..9a46a79456 100644 --- a/src/codecs/tiff.rs +++ b/src/codecs/tiff.rs @@ -18,7 +18,7 @@ use crate::error::{ ParameterError, ParameterErrorKind, UnsupportedError, UnsupportedErrorKind, }; use crate::image::{ImageDecoder, ImageEncoder, ImageFormat}; -use crate::Orientation; +use crate::metadata::Orientation; /// Decoder for TIFF images. pub struct TiffDecoder diff --git a/src/codecs/webp/decoder.rs b/src/codecs/webp/decoder.rs index 67a780de98..1f20191b92 100644 --- a/src/codecs/webp/decoder.rs +++ b/src/codecs/webp/decoder.rs @@ -3,9 +3,8 @@ use std::io::{BufRead, Read, Seek}; use crate::buffer::ConvertBuffer; use crate::error::{DecodingError, ImageError, ImageResult}; use crate::image::{ImageDecoder, ImageFormat}; -use crate::{ - AnimationDecoder, ColorType, Delay, Frame, Frames, Orientation, RgbImage, Rgba, RgbaImage, -}; +use crate::metadata::Orientation; +use crate::{AnimationDecoder, ColorType, Delay, Frame, Frames, RgbImage, Rgba, RgbaImage}; /// WebP Image format decoder. /// diff --git a/src/dynimage.rs b/src/dynimage.rs index 273ac03a38..cbb9c2d517 100644 --- a/src/dynimage.rs +++ b/src/dynimage.rs @@ -16,10 +16,11 @@ use crate::flat::FlatSamples; use crate::image::{GenericImage, GenericImageView, ImageDecoder, ImageEncoder, ImageFormat}; use crate::image_reader::free_functions; use crate::math::resize_dimensions; +use crate::metadata::Orientation; use crate::traits::Pixel; +use crate::ImageReader; use crate::{image, Luma, LumaA}; use crate::{imageops, ExtendedColorType}; -use crate::{ImageReader, Orientation}; use crate::{Rgb32FImage, Rgba32FImage}; /// A Dynamic Image @@ -940,7 +941,7 @@ impl DynamicImage { /// /// ``` /// # fn only_check_if_this_compiles() -> Result<(), Box> { - /// use image::{Orientation, DynamicImage, ImageReader, ImageDecoder}; + /// use image::{DynamicImage, ImageReader, ImageDecoder, metadata::Orientation}; /// /// let mut decoder = ImageReader::open("file.jpg")?.into_decoder()?; /// let orientation = decoder.orientation()?; diff --git a/src/image.rs b/src/image.rs index 74822d4173..e2bddf3a29 100644 --- a/src/image.rs +++ b/src/image.rs @@ -11,8 +11,9 @@ use crate::error::{ ParameterErrorKind, UnsupportedError, UnsupportedErrorKind, }; use crate::math::Rect; +use crate::metadata::Orientation; use crate::traits::Pixel; -use crate::{ImageBuffer, Orientation}; +use crate::ImageBuffer; use crate::animation::Frames; diff --git a/src/lib.rs b/src/lib.rs index e34d754709..32b25fb924 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,7 +172,6 @@ pub use crate::image_reader::{ImageReader, LimitSupport, Limits}; pub use crate::dynimage::DynamicImage; pub use crate::animation::{Delay, Frame, Frames}; -pub use crate::metadata::Orientation; // More detailed error type pub mod error; @@ -290,7 +289,7 @@ mod color; mod dynimage; mod image; mod image_reader; -mod metadata; +pub mod metadata; //TODO delete this module after a few releases /// deprecated io module the original io module has been renamed to `image_reader` pub mod io { diff --git a/src/metadata.rs b/src/metadata.rs index 01da89bc6c..5c2e308770 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,3 +1,5 @@ +//! Types describing image metadata + use std::io::{Cursor, Read}; use byteorder_lite::{BigEndian, LittleEndian, ReadBytesExt};