HEIF IO

Read and write HEIF images.

Summary
HEIF IORead and write HEIF images.
Functions
gdImageCreateFromHeifgdImageCreateFromHeif is called to load truecolor images from HEIF format files.
gdImageCreateFromHeifPtrSee gdImageCreateFromHeif.
gdImageCreateFromHeifCtxSee gdImageCreateFromHeif.
gdImageHeifCtxWrite the image as HEIF data via a gdIOCtx.
gdImageHeifExgdImageHeifEx outputs the specified image to the specified file in HEIF format.
gdImageHeifVariant of gdImageHeifEx which uses the default quality (-1), the default codec (GD_HEIF_Codec_HEVC) and the default chroma subsampling (GD_HEIF_CHROMA_444).
gdImageHeifPtrSee gdImageHeifEx.
gdImageHeifPtrExSee gdImageHeifEx.

Functions

gdImageCreateFromHeif

gdImagePtr gdImageCreateFromHeif(FILE *inFile)

gdImageCreateFromHeif is called to load truecolor images from HEIF format files.  Invoke gdImageCreateFromHeif with an already opened pointer to a file containing the desired image.  gdImageCreateFromHeif returns a gdImagePtr to the new truecolor image, or NULL if unable to load the image (most often because the file is corrupt or does not contain a HEIF image).  gdImageCreateFromHeif does not close the file.

You can inspect the sx and sy members of the image to determine its size.  The image must eventually be destroyed using gdImageDestroy.

The returned image is always a truecolor image.

Parameters

infileThe input FILE pointer.

Returns

A pointer to the new truecolor image.  This will need to be destroyed with gdImageDestroy once it is no longer needed.

On error, returns NULL.

gdImageCreateFromHeifPtr

gdImagePtr gdImageCreateFromHeifPtr(int size,
void *data)

See gdImageCreateFromHeif.

Parameters

sizesize of HEIF data in bytes.
datapointer to HEIF data.

gdImageCreateFromHeifCtx

gdImagePtr gdImageCreateFromHeifCtx(gdIOCtx *infile)

See gdImageCreateFromHeif.

gdImageHeifCtx

void gdImageHeifCtx(gdImagePtr im,
gdIOCtx *outfile,
int quality,
gdHeifCodec codec,
gdHeifChroma chroma)

Write the image as HEIF data via a gdIOCtx.  See gdImageHeifEx for more details.

Parameters

imThe image to write.
outfileThe output sink.
qualityImage quality.
codecThe output coding format.
chromaThe output chroma subsampling format.

Returns

Nothing.

gdImageHeifEx

void gdImageHeifEx(gdImagePtr im,
FILE *outFile,
int quality,
gdHeifCodec codec,
gdHeifChroma chroma)

gdImageHeifEx outputs the specified image to the specified file in HEIF format.  The file must be open for writing.  Under MSDOS and all versions of Windows, it is important to use “wb” as opposed to simply “w” as the mode when opening the file, and under Unix there is no penalty for doing so.  gdImageHeifEx does not close the file; your code must do so.

If quality is -1, a reasonable quality value (which should yield a good general quality / size tradeoff for most situations) is used.  Otherwise quality should be a value in the range 0-100, higher quality values usually implying both higher quality and larger image sizes or 200, for lossless codec.

Variants

gdImageHeifCtx stores the image using a gdIOCtx struct.

gdImageHeifPtrEx stores the image to RAM.

Parameters

imThe image to save.
outFileThe FILE pointer to write to.
qualityCodec quality (0-100).
codecThe output coding format.
chromaThe output chroma subsampling format.

Returns

Nothing.

gdImageHeif

void gdImageHeif(gdImagePtr im,
FILE *outFile)

Variant of gdImageHeifEx which uses the default quality (-1), the default codec (GD_HEIF_Codec_HEVC) and the default chroma subsampling (GD_HEIF_CHROMA_444).

Parameters

imThe image to save
outFileThe FILE pointer to write to.

Returns

Nothing.

gdImageHeifPtr

void * gdImageHeifPtr(gdImagePtr im,
int *size)

See gdImageHeifEx.

gdImageHeifPtrEx

void * gdImageHeifPtrEx(gdImagePtr im,
int *size,
int quality,
gdHeifCodec codec,
gdHeifChroma chroma)

See gdImageHeifEx.

gdImagePtr gdImageCreateFromHeif(FILE *inFile)
gdImageCreateFromHeif is called to load truecolor images from HEIF format files.
gdImagePtr gdImageCreateFromHeifPtr(int size,
void *data)
See gdImageCreateFromHeif.
gdImagePtr gdImageCreateFromHeifCtx(gdIOCtx *infile)
See gdImageCreateFromHeif.
void gdImageHeifCtx(gdImagePtr im,
gdIOCtx *outfile,
int quality,
gdHeifCodec codec,
gdHeifChroma chroma)
Write the image as HEIF data via a gdIOCtx.
gdIOCtx structures hold function pointers for doing image IO.
void gdImageHeifEx(gdImagePtr im,
FILE *outFile,
int quality,
gdHeifCodec codec,
gdHeifChroma chroma)
gdImageHeifEx outputs the specified image to the specified file in HEIF format.
void gdImageHeif(gdImagePtr im,
FILE *outFile)
Variant of gdImageHeifEx which uses the default quality (-1), the default codec (GD_HEIF_Codec_HEVC) and the default chroma subsampling (GD_HEIF_CHROMA_444).
void * gdImageHeifPtr(gdImagePtr im,
int *size)
See gdImageHeifEx.
void * gdImageHeifPtrEx(gdImagePtr im,
int *size,
int quality,
gdHeifCodec codec,
gdHeifChroma chroma)
See gdImageHeifEx.
The data structure in which gd stores images.
void gdImageDestroy (gdImagePtr im)
gdImageDestroy is used to free the memory associated with an image.
Close