# HEIF IO

Read and write HEIF images.

Summary

HEIF IO | Read and write HEIF images.
Functions |
gdImageCreateFromHeif | gdImageCreateFromHeif is called to load truecolor images from HEIF format files.
gdImageCreateFromHeifPtr | See gdImageCreateFromHeif.
gdImageCreateFromHeifCtx | See gdImageCreateFromHeif.
gdImageHeifCtx | Write the image as HEIF data via a gdIOCtx.
gdImageHeifEx | gdImageHeifEx outputs the specified image to the specified file in HEIF format.
gdImageHeif | 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).
gdImageHeifPtr | See gdImageHeifEx.
gdImageHeifPtrEx | See 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

infile | The 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

size | size of HEIF data in bytes.
data | pointer 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

im | The image to write.
outfile | The output sink.
quality | Image quality.
codec | The output coding format.
chroma | The 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

im | The image to save.
outFile | The FILE pointer to write to.
quality | Codec quality (0-100).
codec | The output coding format.
chroma | The 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

im | The image to save
outFile | The 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