Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_tiff.h File Reference

Reading the tags of a TIFF structured buffer. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for n_tiff.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  N_TIFF
 The first directory of a TIFF structured buffer. More...
struct  N_TIFF_ENTRY
 One directory entry. More...

Macros

#define N_TIFF_MAGIC   42
 The magic of a plain TIFF file.
#define N_TIFF_MAGIC_DCP   0x4352
 The magic of an Adobe DCP camera profile, "RC" read little endian.

Functions

size_t n_tiff_count (const N_TIFF *tiff, uint16_t tag)
 How many values a tag has.
const N_TIFF_ENTRY * n_tiff_find (const N_TIFF *tiff, uint16_t tag)
 Find an entry by tag.
void n_tiff_free (N_TIFF **tiff)
 Release a parse, and set the pointer to NULL.
int n_tiff_get_ascii (const N_TIFF *tiff, uint16_t tag, char *out, size_t out_len)
 Read an ASCII tag.
size_t n_tiff_get_doubles (const N_TIFF *tiff, uint16_t tag, double *out, size_t max)
 Read a numeric tag as doubles.
N_TIFF * n_tiff_parse (const unsigned char *data, size_t len)
 Parse the first directory of a TIFF structured buffer.

Detailed Description

Reading the tags of a TIFF structured buffer.

TIFF is a container more than an image format: DNG, Adobe's DCP camera profiles, EXIF blocks and several camera RAW formats are all a header and directories of tagged values. This reads the first directory (IFD0) of such a buffer and hands its values back by tag number, converted: every numeric type as doubles, ASCII as a string.

Both byte orders are read. The 16 bit magic after the byte order mark is reported rather than checked, since the formats built on TIFF change it (42 for TIFF, 0x4352 "RC" for a DCP, 0x55 for Panasonic RW2, 0x4f52 for an Olympus ORF): the caller decides what it accepts.

Everything is checked against the buffer's length: a directory, a count or an offset that points outside it makes the entry, or the whole parse, fail rather than read out of bounds. The buffer is borrowed and must outlive the N_TIFF.

Author
Castagnier Mickael
Version
1.0
Date
28/09/2026

Definition in file n_tiff.h.