Read and write AV1 Image File Format images.
More...
|
| void | gdImageAvif (gdImagePtr im, FILE *outFile) |
| | Write a truecolor image as AVIF data to a stdio stream.
|
| |
| void | gdImageAvifEx (gdImagePtr im, FILE *outFile, int quality, int speed) |
| | Write a truecolor image as AVIF data to a stdio stream.
|
| |
| void * | gdImageAvifPtr (gdImagePtr im, int *size) |
| | Encode a truecolor image as AVIF data in memory.
|
| |
| void * | gdImageAvifPtrEx (gdImagePtr im, int *size, int quality, int speed) |
| | Encode a truecolor image as AVIF data in memory.
|
| |
| void * | gdImageAvifPtrWithOptions (gdImagePtr im, int *size, const gdAvifWriteOptions *options) |
| | Encode a truecolor image as AVIF data in memory using write options.
|
| |
|
int | gdImageAvifWithOptions (gdImagePtr im, FILE *outFile, const gdAvifWriteOptions *options) |
| | Write AVIF data to a stdio stream using write options.
|
| |
|
int | gdImageAvifCtxWithOptions (gdImagePtr im, gdIOCtxPtr outfile, const gdAvifWriteOptions *options) |
| | Write AVIF data to a gdIOCtx using write options.
|
| |
| void | gdImageAvifCtx (gdImagePtr im, gdIOCtxPtr outfile, int quality, int speed) |
| | Write a truecolor image as AVIF data to an IO context.
|
| |
Read and write AV1 Image File Format images.
AVIF support reads AVIF data from stdio streams, memory buffers, or gd IO contexts and returns truecolor images. If the AVIF input contains an image sequence, gd reads the first image and ignores subsequent frames. AVIF writing accepts truecolor images and can write to stdio streams, memory buffers, or gd IO contexts with quality, speed, lossless, and chroma-subsampling options.
FILE *in;
void *data;
int size;
in = fopen("input.avif", "rb");
if (in == NULL) {
return 1;
}
fclose(in);
return 1;
}
if (data != NULL) {
gdFree(data);
}
void gdAvifWriteOptionsInit(gdAvifWriteOptions *options)
Initialize AVIF write options with gd defaults.
Definition gd_avif.c:674
void * gdImageAvifPtrWithOptions(gdImagePtr im, int *size, const gdAvifWriteOptions *options)
Encode a truecolor image as AVIF data in memory using write options.
Definition gd_avif.c:750
gdImagePtr gdImageCreateFromAvif(FILE *inFile)
Create a truecolor image from AVIF data in a stdio stream.
Definition gd_avif.c:685
@ GD_AVIF_CHROMA_SUBSAMPLING_YUV444
Definition gd.h:3466
Write an image as JPEG data to a gdIOCtx.
AVIF encoder options used by gdImageAvifPtrWithOptions().
Definition gd.h:3479
int speed
Definition gd.h:3481
int chroma_subsampling
Definition gd.h:3483
int quality
Definition gd.h:3480
◆ anonymous enum
AVIF chroma subsampling modes for gdAvifWriteOptions::chroma_subsampling.
| Enumerator |
|---|
| GD_AVIF_CHROMA_SUBSAMPLING_AUTO | Choose subsampling automatically from the quality settings.
|
| GD_AVIF_CHROMA_SUBSAMPLING_YUV420 | Use 4:2:0 chroma subsampling.
|
| GD_AVIF_CHROMA_SUBSAMPLING_YUV444 | Use 4:4:4 chroma subsampling.
|
◆ anonymous enum
◆ gdAvifGetInfo()
| int gdAvifGetInfo |
( |
FILE * |
inFile, |
|
|
gdAvifInfo * |
info |
|
) |
| |
Read AVIF information from a stdio stream without closing it. *.
- Parameters
-
| inFile | Pointer to the input FILE stream. |
| info | Pointer to the gdAvifInfo structure to populate. |
- Returns
- Returns 1 on success, or 0 on failure.
◆ gdAvifGetInfoCtx()
| int gdAvifGetInfoCtx |
( |
gdIOCtxPtr |
in, |
|
|
gdAvifInfo * |
info |
|
) |
| |
Read AVIF information from a gdIOCtx without closing it.
- Parameters
-
| in | Pointer to the gdIOCtx input context. |
| info | Pointer to the gdAvifInfo structure to populate. |
- Returns
- Returns 1 on success, or 0 on failure.
◆ gdAvifGetInfoPtr()
| int gdAvifGetInfoPtr |
( |
int |
size, |
|
|
const void * |
data, |
|
|
gdAvifInfo * |
info |
|
) |
| |
Read AVIF information from memory without taking ownership.
- Parameters
-
| size | Size of the AVIF memory buffer in bytes. |
| data | Pointer to the AVIF memory buffer. |
| info | Pointer to the gdAvifInfo structure to populate. |
- Returns
- Returns 1 on success, or 0 on failure.
◆ gdAvifInfoInit()
Initialize AVIF information and clear the metadata pointer.
- Parameters
-
| info | Pointer to the gdAvifInfo structure to initialize. |
◆ gdAvifWriteOptionsInit()
Initialize AVIF write options with gd defaults.
Call this before changing selected gdAvifWriteOptions fields and passing the structure to gdImageAvifPtrWithOptions().
- Parameters
-
| options | Pointer to the options structure to initialize. |
◆ gdImageAvif()
| void gdImageAvif |
( |
gdImagePtr |
im, |
|
|
FILE * |
outFile |
|
) |
| |
Write a truecolor image as AVIF data to a stdio stream.
gdImageAvif() uses gd's default AVIF quality and speed settings. The image is borrowed for the duration of the call, and outFile is not closed.
- Parameters
-
| im | The truecolor image to write. |
| outFile | Pointer to the output FILE stream. |
◆ gdImageAvifCtx()
| void gdImageAvifCtx |
( |
gdImagePtr |
im, |
|
|
gdIOCtxPtr |
outfile, |
|
|
int |
quality, |
|
|
int |
speed |
|
) |
| |
Write a truecolor image as AVIF data to an IO context.
gdImageAvifCtx() writes im with explicit quality and speed settings. Quality values range from 0 to 100, with higher values improving quality and 100 requesting lossless output; -1 selects the default. Speed is passed to the AVIF encoder and clamped to its supported range. The image is borrowed for the duration of the call, and outfile is not closed.
- Parameters
-
| im | The truecolor image to write. |
| outfile | The output IO context. |
| quality | Compression quality from 0 to 100, or -1 for the default. |
| speed | Encoder speed; lower values are slower and may improve compression. |
◆ gdImageAvifEx()
| void gdImageAvifEx |
( |
gdImagePtr |
im, |
|
|
FILE * |
outFile, |
|
|
int |
quality, |
|
|
int |
speed |
|
) |
| |
Write a truecolor image as AVIF data to a stdio stream.
gdImageAvifEx() writes im with explicit quality and speed settings. Quality values range from 0 to 100, with higher values improving quality and 100 requesting lossless output; -1 selects the default. Speed is passed to the AVIF encoder and clamped to its supported range. The image is borrowed for the duration of the call, and outFile is not closed.
- Parameters
-
| im | The truecolor image to write. |
| outFile | Pointer to the output FILE stream. |
| quality | Compression quality from 0 to 100, or -1 for the default. |
| speed | Encoder speed; lower values are slower and may improve compression. |
◆ gdImageAvifPtr()
| void * gdImageAvifPtr |
( |
gdImagePtr |
im, |
|
|
int * |
size |
|
) |
| |
Encode a truecolor image as AVIF data in memory.
gdImageAvifPtr() uses gd's default AVIF quality and speed settings. The image is borrowed for the duration of the call. On success, the returned buffer is owned by the caller and must be freed with gdFree().
- Parameters
-
| im | The truecolor image to encode. |
| size | Pointer that receives the encoded buffer size in bytes. |
- Returns
- A newly allocated AVIF data buffer, or NULL on error.
◆ gdImageAvifPtrEx()
| void * gdImageAvifPtrEx |
( |
gdImagePtr |
im, |
|
|
int * |
size, |
|
|
int |
quality, |
|
|
int |
speed |
|
) |
| |
Encode a truecolor image as AVIF data in memory.
gdImageAvifPtrEx() writes im with explicit quality and speed settings. Quality values range from 0 to 100, with higher values improving quality and 100 requesting lossless output; -1 selects the default. Speed is passed to the AVIF encoder and clamped to its supported range. The image is borrowed for the duration of the call. On success, the returned buffer is owned by the caller and must be freed with gdFree().
- Parameters
-
| im | The truecolor image to encode. |
| size | Pointer that receives the encoded buffer size in bytes. |
| quality | Compression quality from 0 to 100, or -1 for the default. |
| speed | Encoder speed; lower values are slower and may improve compression. |
- Returns
- A newly allocated AVIF data buffer, or NULL on error.
◆ gdImageAvifPtrWithOptions()
| void * gdImageAvifPtrWithOptions |
( |
gdImagePtr |
im, |
|
|
int * |
size, |
|
|
const gdAvifWriteOptions * |
options |
|
) |
| |
Encode a truecolor image as AVIF data in memory using write options.
gdImageAvifPtrWithOptions() borrows im and options for the duration of the call. Pass NULL for options to use gd defaults. On success, the returned buffer is owned by the caller and must be freed with gdFree().
- Parameters
-
| im | The truecolor image to encode. |
| size | Pointer that receives the encoded buffer size in bytes. |
| options | AVIF encoder options, or NULL for defaults. |
- Returns
- A newly allocated AVIF data buffer, or NULL on error.
◆ gdImageCreateFromAvif()
| gdImagePtr gdImageCreateFromAvif |
( |
FILE * |
inFile | ) |
|
Create a truecolor image from AVIF data in a stdio stream.
gdImageCreateFromAvif() does not close inFile. If the AVIF contains an image sequence, only the first image is decoded. On success, the returned image is owned by the caller and must be destroyed with gdImageDestroy.
- Parameters
-
| inFile | Pointer to the input FILE stream. |
- Returns
- A newly allocated truecolor image, or NULL on error.
◆ gdImageCreateFromAvifCtx()
| gdImagePtr gdImageCreateFromAvifCtx |
( |
gdIOCtxPtr |
infile | ) |
|
Create a truecolor image from AVIF data in an IO context.
gdImageCreateFromAvifCtx() reads from infile without closing it. If the AVIF contains an image sequence, only the first image is decoded. On success, the returned image is owned by the caller and must be destroyed with gdImageDestroy.
- Parameters
-
| infile | The input IO context. |
- Returns
- A newly allocated truecolor image, or NULL on error.
◆ gdImageCreateFromAvifPtr()
| gdImagePtr gdImageCreateFromAvifPtr |
( |
int |
size, |
|
|
void * |
data |
|
) |
| |
Create a truecolor image from AVIF data in memory.
gdImageCreateFromAvifPtr() reads size bytes from data without taking ownership of the buffer. If the AVIF contains an image sequence, only the first image is decoded. On success, the returned image is owned by the caller and must be destroyed with gdImageDestroy.
- Parameters
-
| size | Size of data in bytes. |
| data | Pointer to the AVIF data. |
- Returns
- A newly allocated truecolor image, or NULL on error.