# WebP IO

Read and write WebP images.

Summary

WebP IO | Read and write WebP images.
Functions |
gdImageCreateFromWebp | gdImageCreateFromWebp is called to load truecolor images from WebP format files.
gdImageCreateFromWebpPtr | See gdImageCreateFromWebp.
gdImageCreateFromWebpCtx | See gdImageCreateFromWebp.
gdImageWebpCtx | Write the image as WebP data via a gdIOCtx.
gdImageWebpEx | gdImageWebpEx outputs the specified image to the specified file in WebP format.
gdImageWebp | Variant of gdImageWebpEx which uses the default quality (-1).
gdImageWebpPtr | See gdImageWebpEx.
gdImageWebpPtrEx | See 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

gdImageCreateFromJpegPtr creates an image from WebP data already in memory.

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

#### 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.

### gdImageCreateFromWebpPtr

> gdImagePtr gdImageCreateFromWebpPtr ( | int |  | size,
> | void | * | data | )

See gdImageCreateFromWebp.

#### Parameters

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

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

#### Variants

gdImageWebpCtx stores the image using a gdIOCtx struct.

gdImageWebpPtrEx stores the image to RAM.

#### Parameters

im | The image to save.
outFile | The FILE pointer to write to.
quality | Compression quality (0-100).

#### Returns

Nothing.

### gdImageWebp

> void gdImageWebp ( | gdImagePtr |  | im,
> | FILE | * | outFile | )

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

#### Parameters

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

> gdImagePtr gdImageCreateFromJpegPtr( | int |  | size,
> | void | * | data | )

> gdImagePtr gdImageCreateFromJpegCtx( | gdIOCtx | * | infile | )

See gdImageCreateFromJpeg.
Close