ICC: embedded colour profiles of image files
Functions
| Name | |
|---|---|
| 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. |
| 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_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. |
Defines
| Name | |
|---|---|
| N_ICC_MAX_BYTES Largest profile returned. |
|
| N_ICC_HEAD_BYTES 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. |
Functions Documentation
function n_icc_is_profile
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.
Parameters:
- data the bytes
- len how many
Return: 1 when it does, 0 otherwise
function n_icc_from_file
int n_icc_from_file(
const char * path,
unsigned char ** icc,
size_t * icc_len
)
Find the profile embedded in an image file.
Parameters:
- path the file
- icc as n_icc_from_buffer()
- icc_len as n_icc_from_buffer()
Return: as n_icc_from_buffer(), and -1 when the file cannot be read
A TIFF's profile is read where its directory says, which may be at the end of a large file; for the other formats the first N_ICC_HEAD_BYTES are read.
function n_icc_from_buffer
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.
Parameters:
- data the file's bytes, from its start
- len how many
- icc receives the profile, allocated here and released with free(), or NULL when there is none
- icc_len receives its length, 0 when there is none
Return: 1 when a profile was found, 0 when the file has none or is not a format read here, -1 on a NULL argument, no memory or a profile that is there but broken
The format is told from the buffer's first bytes, not from a name.
Macros Documentation
define N_ICC_MAX_BYTES
#define N_ICC_MAX_BYTES (16u * 1024u * 1024u)
Largest profile returned.
Real ones are a few hundred bytes to a few hundred kilobytes, a large lookup table profile a few megabytes.
define N_ICC_HEAD_BYTES
#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.
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB