Skip to content

Commit e5d170a

Browse files
authored
README.md
1 parent 190a255 commit e5d170a

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# MicroEXIF Library Overview
2+
3+
The MicroEXIF library is a lightweight library for adding and EXIF metadata in JPEG files. It provides an easy way to create, configure, and inject EXIF metadata into JPEG images using a set of well-defined classes and structures.
4+
5+
## Core Components
6+
7+
### ExifTag Structure
8+
9+
The `ExifTag` structure represents individual EXIF metadata tags. Each tag consists of:
10+
11+
- **tag (uint16\_t)**: The tag ID uniquely identifies the metadata type (e.g., `0x010F` for Manufacturer).
12+
- **type (uint16\_t)**: Specifies the type of data for the tag, such as `BYTE`, `ASCII`, `SHORT`, `LONG`, `RATIONAL`, etc.
13+
- **count (uint32\_t)**: Number of values represented by this tag.
14+
- **value (std::vector\<uint8\_t>)**: Stores the tag value data.
15+
16+
The `ExifTag` structure has multiple constructors for different tag types (e.g., `BYTE`, `SHORT`, `LONG`, `RATIONAL`, `ASCII`), making it easy to create and add tags with various types of data.
17+
18+
### ExifBuilder Class
19+
20+
The `ExifBuilder` class allows you to construct a complete EXIF metadata block by combining multiple `ExifTag` instances. Its key features include:
21+
22+
- **Adding Tags**: You can add EXIF metadata tags to the builder using the `addTag()` method.
23+
- **Building the EXIF Blob**: The `buildExifBlob()` method compiles all the added tags into a complete EXIF metadata blob that can be injected into a JPEG file.
24+
25+
The `ExifBuilder` Internally manages EXIF data alignment (big-endian/little-endian) and handles the concatenation of multiple tags into a valid EXIF structure that adheres to the TIFF/EXIF specifications.
26+
27+
## Usage Example
28+
29+
To use the MicroEXIF library, follow these general steps:
30+
31+
1. **Create an `ExifBuilder` instance**.
32+
2. **Add EXIF tags** using `ExifTag` constructors.
33+
3. **Build the EXIF blob** and inject it into a JPEG file.
34+
35+
```cpp
36+
#include "MicroExif.h"
37+
38+
ExifBuilder builder;
39+
40+
// Add Manufacturer tag
41+
builder.addTag(ExifTag(0x010F, 0x0002, "Ximea"));
42+
// Add Model tag
43+
builder.addTag(ExifTag(0x0110, 0x0002, "MX245CG-SY-X4G3-FF"));
44+
// Add Exposure Time (RATIONAL)
45+
builder.addTag(ExifTag(0x829A, 0x0005, 1, 1, 100));
46+
47+
// Build EXIF Blob
48+
std::vector<uint8_t> exifBlob = builder.buildExifBlob();
49+
```
50+
Example code to find `FFDB` marker and inject EXIF blob after it:
51+
52+
```cpp
53+
// Example code to inject the EXIF blob into a JPEG file
54+
writeNewJpegWithExif("input.jpg", "output_exif.jpg", exifBlob.data(), exifBlob.size());
55+
```
56+

0 commit comments

Comments
 (0)