![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Finding the ICC colour profile embedded in an image file. More...
#include <stddef.h>Go to the source code of this file.
Macros | |
| #define | N_ICC_HEAD_BYTES (N_ICC_MAX_BYTES + 1024u * 1024u) |
| Bytes of a file n_icc_from_file() reads to look for a JPEG, PNG or WebP profile, which those formats keep before the image data. | |
| #define | N_ICC_MAX_BYTES (16u * 1024u * 1024u) |
| Largest profile returned. | |
Functions | |
| int | n_icc_from_buffer (const unsigned char *data, size_t len, unsigned char **icc, size_t *icc_len) |
| Find the profile embedded in an image file held in memory. | |
| int | n_icc_from_file (const char *path, unsigned char **icc, size_t *icc_len) |
| Find the profile embedded in an image file. | |
| int | n_icc_is_profile (const unsigned char *data, size_t len) |
| Does a buffer look like an ICC profile: at least a header, a size field no larger than the buffer, and "acsp" at byte 36. | |
Finding the ICC colour profile embedded in an image file.
A JPEG, PNG, TIFF or WebP file can carry the ICC profile that says what its numbers mean: Adobe RGB, Display P3, ProPhoto, a camera's or a scanner's. Each format keeps it its own way, and this returns the profile's bytes whichever it is:
What is found is checked to look like a profile (its size field and the "acsp" signature) before it is returned. Nothing here interprets the profile: that is a colour management library's work.
Everything is bounded by the buffer's length and by N_ICC_MAX_BYTES; a truncated or hostile file makes the search fail, never read out of bounds.
Definition in file n_icc.h.