WebP IO

Read and write WebP images.

Summary
WebP IORead and write WebP images.
Functions
gdImageCreateFromWebpgdImageCreateFromWebp is called to load truecolor images from WebP format files.
gdImageCreateFromWebpPtrSee gdImageCreateFromWebp.
gdImageCreateFromWebpCtxSee gdImageCreateFromWebp.
gdImageWebpCtxWrite the image as WebP data via a gdIOCtx.
gdImageWebpExgdImageWebpEx outputs the specified image to the specified file in WebP format.
gdImageWebpVariant of gdImageWebpEx which uses the default quality (-1).
gdImageWebpPtrSee gdImageWebpEx.
gdImageWebpPtrExSee gdImageWebpEx.

Functions

gdImageCreateFromWebp

gdImagePtr gdImageCreateFromWebp (FILE *inFile)

gdImageCreateFromWebp is called to load truecolor images from WebP format files.  Invoke gdImageCreateFromWebp with an already opened pointer to a file containing the desired image.  gdImageCreateFromWebp 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 WebP image).  gdImageCreateFromWebp 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.

Variants

gdImageCreateFromWebpPtr creates an image from WebP data already in memory.

gdImageCreateFromWebpCtx reads its data via the function pointers in a gdIOCtx structure.

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.

gdImageCreateFromWebpPtr

gdImagePtr gdImageCreateFromWebpPtr (int size,
void *data)

See gdImageCreateFromWebp.

Parameters

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

gdImageCreateFromWebpCtx

gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx *infile)

See gdImageCreateFromWebp.

gdImageWebpCtx

void gdImageWebpCtx (gdImagePtr im,
gdIOCtx *outfile,
int quality)

Write the image as WebP data via a gdIOCtx.  See gdImageWebpEx for more details.

Parameters

imThe image to write.
outfileThe output sink.
qualityImage quality.

Returns

Nothing.

gdImageWebpEx

void gdImageWebpEx (gdImagePtr im,
FILE *outFile,
int quality)

gdImageWebpEx outputs the specified image to the specified file in WebP 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.  gdImageWebpEx 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.

If quality is greater than or equal to gdWebpLossless then the image will be written in the lossless WebP format.

Variants

gdImageWebpCtx stores the image using a gdIOCtx struct.

gdImageWebpPtrEx stores the image to RAM.

Parameters

imThe image to save.
outFileThe FILE pointer to write to.
qualityCompression quality (0-100).

Returns

Nothing.

gdImageWebp

void gdImageWebp (gdImagePtr im,
FILE *outFile)

Variant of gdImageWebpEx which uses the default quality (-1).

Parameters

imThe image to save
outFileThe FILE pointer to write to.

Returns

Nothing.

gdImageWebpPtr

void * gdImageWebpPtr (gdImagePtr im,
int *size)

See gdImageWebpEx.

gdImageWebpPtrEx

void * gdImageWebpPtrEx (gdImagePtr im,
int *size,
int quality)

See gdImageWebpEx.

gdImagePtr gdImageCreateFromWebp (FILE *inFile)
gdImageCreateFromWebp is called to load truecolor images from WebP format files.
gdImagePtr gdImageCreateFromWebpPtr (int size,
void *data)
See gdImageCreateFromWebp.
gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx *infile)
See gdImageCreateFromWebp.
void gdImageWebpCtx (gdImagePtr im,
gdIOCtx *outfile,
int quality)
Write the image as WebP data via a gdIOCtx.
gdIOCtx structures hold function pointers for doing image IO.
void gdImageWebpEx (gdImagePtr im,
FILE *outFile,
int quality)
gdImageWebpEx outputs the specified image to the specified file in WebP format.
void gdImageWebp (gdImagePtr im,
FILE *outFile)
Variant of gdImageWebpEx which uses the default quality (-1).
void * gdImageWebpPtr (gdImagePtr im,
int *size)
See gdImageWebpEx.
void * gdImageWebpPtrEx (gdImagePtr im,
int *size,
int quality)
See gdImageWebpEx.
The data structure in which gd stores images.
void gdImageDestroy (gdImagePtr im)
gdImageDestroy is used to free the memory associated with an image.
Lossless quality threshold.
Close