MCPcopy Index your code
hub / github.com/TechnikTobi/little_exif

github.com/TechnikTobi/little_exif @v0.6.23

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.23 ↗ · + Follow
398 symbols 1,279 edges 79 files 61 documented · 15%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

little_exif

A little library for reading and writing EXIF data in pure Rust.

Build & Test  version-badge  license-badge 

Supported Formats

  • JPEG / JPG
  • JXL
  • HEIF / HEIC / HIF / AVIF
  • PNG
  • TIFF
  • WebP (only lossless and extended)

Your required format is not listed here or you've run into a problem with a file that should be supported? Open up a new issue (ideally with an example image for reproduction in case of a problem) and I'll take a look!

Example

If the image is stored in a file, located at some given path:

use little_exif::metadata::Metadata;
use little_exif::exif_tag::ExifTag;

let image_path = std::path::Path::new("image.png");
let mut metadata = Metadata::new_from_path(&image_path);

metadata.set_tag(
    ExifTag::ImageDescription("Hello World!".to_string())
);

metadata.write_to_file(&image_path)?;

Alternatively, if the image is stored in a Vec<u8> variable:

use little_exif::metadata::Metadata;
use little_exif::exif_tag::ExifTag;
use little_exif::filetype::FileExtension;

let file_type = FileExtension::JPEG;
let mut metadata = Metadata::new_from_vec(&image_vector, file_type);

metadata.set_tag(
    ExifTag::ImageDescription("Hello World!".to_string())
);

metadata.write_to_vec(&mut image_vector, file_type)?;

Testing

To run the tests from a specific file, use e.g.

cargo test --test issue_000002

To run a single test from that file use

cargo test --test issue_000002 read_and_write_exif_data_1

Logging

This library uses the log crate for various levels of logging.

Setup

To enable this logging, you will need to add & initialize a logger implementation, such as env_logger, but there are other loggers available, see the list on available logging implementations in the log crate.

Add the implementation to your crate:

cargo add env_logger

Initialize the logger in your application:

fn main() 
{
    env_logger::init();

    // your little_exif code ...
}

Usage

In env_logger, you can view little_exif's debug-level logs, for example, by setting the RUST_LOG env var:

env RUST_LOG=debug cargo run

For other log levels, see env_logger's documentation or the documentation of the logger of your choice.

FAQ

I tried writing the ImageDescription tag on a JPEG file, but it does not show up. Why?

This could be due to the such called APP12 or APP13 segment stored in the JPEG, likely caused by editing the file using e.g. Photoshop. These segments may store data that image viewers also interpret as an ImageDescription, overriding the EXIF tag. Right now, little_exif can't edit these segments. As a workaround, the functions clear_app12_segment and clear_app13_segment can remove these areas from the JPEG:

// File in a Vec<u8>
Metadata::clear_app12_segment(&mut file_content, file_extension)?;
Metadata::clear_app13_segment(&mut file_content, file_extension)?;

// File at a given path
Metadata::file_clear_app12_segment(&given_path)?;
Metadata::file_clear_app13_segment(&given_path)?;

License

Licensed under either

  • Apache License, Version 2.0 (See LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or
  • MIT License (See LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Extension points exported contracts — how you extend this code

GenericIsoBox (Interface)
(no doc) [8 implementers]
src/heif/boxes/mod.rs
U8conversion (Interface)
(no doc) [3 implementers]
src/u8conversion.rs
ParsableIsoBox (Interface)
(no doc) [6 implementers]
src/heif/boxes/mod.rs

Core symbols most depended-on inside this repo

len
called by 94
src/webp/riff_chunk.rs
set_tag
called by 42
src/ifd/set.rs
write_to_file
called by 23
src/metadata/metadata_io.rs
into_iter
called by 19
src/metadata/iterator.rs
get_tag_by_hex
called by 19
src/metadata/get.rs
get_box_size
called by 19
src/heif/box_header.rs
get_generic_ifd_nr
called by 19
src/ifd/get.rs
read_be_u32
called by 18
src/util.rs

Shape

Function 233
Method 133
Class 21
Enum 8
Interface 3

Languages

Rust100%

Modules by API surface

tests/main.rs42 symbols
src/png/mod.rs23 symbols
src/jxl.rs16 symbols
src/heif/boxes/item_location.rs16 symbols
src/jpg.rs14 symbols
src/heif/boxes/meta.rs14 symbols
src/heif/box_header.rs13 symbols
src/webp/vec.rs12 symbols
src/webp/file.rs12 symbols
src/util.rs12 symbols
src/metadata/metadata_io.rs11 symbols
src/heif/container.rs11 symbols

For agents

$ claude mcp add little_exif \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact