zune_image/metadata/exif.rs
1/*
2 * Copyright (c) 2023.
3 *
4 * This software is free software;
5 *
6 * You can redistribute it or modify it under terms of the MIT, Apache License or Zlib license
7 */
8
9#![cfg(feature = "metadata")]
10
11use zune_core::log::{error, trace};
12
13use crate::metadata::ImageMetadata;
14
15impl ImageMetadata {
16 /// Parse raw Exif and store it as a field in the data
17 ///
18 /// Data should point to the first exif byte
19 ///
20 /// This requires the `metadata` feature to be activated
21 /// otherwise it's a compile error
22 #[cfg_attr(feature = "docs", doc(cfg(feature = "metadata")))]
23 pub fn parse_raw_exif(&mut self, data: &[u8]) {
24 trace!("Parsing exif data");
25
26 match exif::parse_exif(data) {
27 Ok(exif) => {
28 self.exif = Some(exif.0);
29 }
30 Err(exif) => {
31 error!("Error while parsing exif chunk {:?}", exif)
32 }
33 };
34 }
35}