Skip to content

Commit

Permalink
Merge pull request #2346 from Shnatsel/orientation-doc-comment
Browse files Browse the repository at this point in the history
Update apply_orientation doc comment to use `.orientation()`
  • Loading branch information
Shnatsel authored Oct 15, 2024
2 parents 3b10606 + e502e48 commit dd87098
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
19 changes: 3 additions & 16 deletions src/dynimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,25 +940,12 @@ impl DynamicImage {
///
/// ```
/// # fn only_check_if_this_compiles() -> Result<(), Box<dyn std::error::Error>> {
/// # 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(())
/// # }
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit dd87098

Please sign in to comment.