Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fedragon/tiff-parser
Parses Exif metadata from TIFF-like files.
https://github.com/fedragon/tiff-parser
exif tiff
Last synced: 20 days ago
JSON representation
Parses Exif metadata from TIFF-like files.
- Host: GitHub
- URL: https://github.com/fedragon/tiff-parser
- Owner: fedragon
- Created: 2023-07-29T18:48:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-31T06:18:19.000Z (over 1 year ago)
- Last Synced: 2024-06-19T20:54:29.679Z (7 months ago)
- Topics: exif, tiff
- Language: Go
- Homepage:
- Size: 35.5 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TIFF parser
Parses Exif metadata from TIFF-like files. Tested on Canon's CR2 and Olympus' ORF files.
## Usage
This library provides a low-level API to parse IFD entries from TIFF files: low-level here means that clients of this library need to provide the _IFD Entry ID_ of any entry they would like to retrieve and they also need to know what is its datatype, so that they can later read it into the appropriate type using the provided `parser.Read*` methods.
This is because there are many manufacturer-specific exceptions to how IFD entries are written, even for basic entries such as `imageWidth` (`uint16` in CR2, `uint32` in ORF).
[ExifTool - Exif Tags](https://exiftool.org/TagNames/EXIF.html) provides a very extensive compendium of all known IFD entries.
### Example
See [examples/main.go](examples/main.go)
## TIFF File structure
```
TIFF header: 8 bytes
CR2 header: 8 bytes
IFD#0:
Number of entries: 2 bytes, ushort
Entry#1: 12 bytes per entry
...
Entry_Exif (pointer to the Exif sub-IFD)
Entry_GPSInfo (pointer to the GPS Info sub-IFD)
...
Entry#N
Pointer to IFD#1: 4 bytes, ulong
Exif sub-IFD:
Number of entries: 2 bytes, ushort
Entry#1: 12 bytes per entry
...
Entry_MakerNote (pointer to the MakerNote sub-IFD)
...
Entry#N
MakerNote sub-IFD:
sequence of bytes containing manufacturer-specific entries, structure depends on manufacturer
GPSInfo sub-IFD: (it may be before or after Exif, it all depends on their respective pointers' values)
Number of entries: 2 bytes
Entry#1 ... Entry#N: 12 bytes per entry
IFD#0 Data Area: variable size
IFD#1:
...
IFD#2:
...
IFD#3:
...
Image#0:
...
Image#1:
...
Image#2:
...
Image#3:
...
```## Credits
The biggest challenge in parsing Exif metadata is that its structure is poorly documented and there are tons of manufacturer-specific exceptions to take into account.
I was able to write this library only thanks to the excellent work created, over the years, by people like Phil Harvey ([ExifTool](https://exiftool.org)) and Laurent Clévy ([Understanding what is stored in a Canon RAW .CR2 file, how and why](http://lclevy.free.fr/cr2/)).