|
LibGd 2.4.0-dev
GD Graphics library
|
WebP image reading, writing and animations support. More...

Data Structures | |
| struct | gdWebpInfo |
| WebP container information. More... | |
| struct | gdWebpFrameInfo |
| WebP animation frame information. More... | |
| struct | gdWebpReadOptions |
| WebP multi-image/animation reader options. More... | |
| struct | gdWebpWriteOptions |
| WebP still-image writer options. More... | |
| struct | gdWebpAnimWriteOptions |
| WebP animation writer options. More... | |
Macros | |
| #define | gdWebpLossless 101 |
| Lossless WebP quality threshold. | |
Functions | |
| void | gdImageWebpEx (gdImagePtr im, FILE *outFile, int quantization) |
| Write an image as WebP data to a stdio file with a quality setting. | |
| void | gdImageWebp (gdImagePtr im, FILE *outFile) |
| Write an image as WebP data to a stdio file with default quality. | |
| void * | gdImageWebpPtr (gdImagePtr im, int *size) |
| Write an image as WebP data to a newly allocated memory buffer. | |
| void * | gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization) |
| Write an image as WebP data to a newly allocated memory buffer with a quality setting. | |
| int | gdImageWebpWithOptions (gdImagePtr im, FILE *outFile, const gdWebpWriteOptions *options) |
| Write an image as WebP data to a stdio file using write options. | |
| int | gdImageWebpCtxWithOptions (gdImagePtr im, gdIOCtxPtr outfile, const gdWebpWriteOptions *options) |
| Write an image as WebP data to a gdIOCtx using write options. | |
| void * | gdImageWebpPtrWithOptions (gdImagePtr im, int *size, const gdWebpWriteOptions *options) |
| Write an image as WebP data to a newly allocated memory buffer using write options. | |
| void | gdImageWebpCtx (gdImagePtr im, gdIOCtxPtr outfile, int quantization) |
| Write an image as WebP data to a gdIOCtx with a quality setting. | |
WebP Types And Constants | |
| enum | { gdWebpDisposeNone , gdWebpDisposeBackground } |
| WebP frame disposal methods. More... | |
| enum | { gdWebpBlendAlpha , gdWebpBlendNone } |
| WebP frame blend methods. More... | |
| typedef struct gdWebpRead * | gdWebpReadPtr |
| Opaque WebP animation reader handle. | |
| typedef struct gdWebpWrite * | gdWebpWritePtr |
| Opaque WebP animation writer handle. | |
| void | gdWebpReadOptionsInit (gdWebpReadOptions *options) |
| Initialize WebP multi-image/animation read options with gd defaults. | |
| void | gdWebpWriteOptionsInit (gdWebpWriteOptions *options) |
| Initialize WebP still-image write options with gd defaults. | |
| void | gdWebpAnimWriteOptionsInit (gdWebpAnimWriteOptions *options) |
| Initialize WebP multi-image/animation write options with gd defaults. | |
Single-Image Reading | |
| gdImagePtr | gdImageCreateFromWebp (FILE *inFile) |
| Create a truecolor image from a WebP stdio file. | |
| gdImagePtr | gdImageCreateFromWebpPtr (int size, void *data) |
| Create a truecolor image from a WebP memory buffer. | |
| gdImagePtr | gdImageCreateFromWebpCtx (gdIOCtxPtr infile) |
| Create a truecolor image from WebP data read through a gdIOCtx. | |
WebP Multi-Image/Animation Reading | |
| int | gdWebpIsAnimated (FILE *fd) |
| Test whether a WebP stdio file contains animation. | |
| int | gdWebpIsAnimatedCtx (gdIOCtxPtr in) |
| Test whether a seekable gdIOCtx contains animated WebP data. | |
| int | gdWebpIsAnimatedPtr (int size, void *data) |
| Test whether a WebP memory buffer contains animation. | |
| gdWebpReadPtr | gdWebpReadOpen (FILE *fd, const gdWebpReadOptions *options) |
| Open a WebP animation reader from a stdio file. | |
| gdWebpReadPtr | gdWebpReadOpenCtx (gdIOCtxPtr in, const gdWebpReadOptions *options) |
| Open a WebP animation reader from a gdIOCtx. | |
| gdWebpReadPtr | gdWebpReadOpenPtr (int size, void *data, const gdWebpReadOptions *options) |
| Open a WebP animation reader from a memory buffer. | |
| void | gdWebpReadClose (gdWebpReadPtr webp) |
| Close a WebP animation reader. | |
| int | gdWebpReadGetInfo (gdWebpReadPtr webp, gdWebpInfo *info) |
| Get WebP container information from a WebP reader. | |
| int | gdWebpReadGetMetadata (gdWebpReadPtr webp, gdImageMetadata *metadata) |
| Extract opaque EXIF, XMP, and ICC metadata from a WebP reader. | |
| int | gdWebpReadNextFrame (gdWebpReadPtr webp, gdWebpFrameInfo *info, gdImagePtr *frame) |
| Read the next raw WebP animation frame rectangle. | |
| int | gdWebpReadNextImage (gdWebpReadPtr webp, gdWebpFrameInfo *info, gdImagePtr *image) |
| Read the next coalesced WebP animation image. | |
WebP Multi-Image/Animation Writing | |
| gdWebpWritePtr | gdWebpWriteOpen (FILE *outFile, const gdWebpAnimWriteOptions *options) |
| Open a WebP animation writer for a stdio file. | |
| gdWebpWritePtr | gdWebpWriteOpenCtx (gdIOCtxPtr out, const gdWebpAnimWriteOptions *options) |
| Open a WebP animation writer for a gdIOCtx. | |
| gdWebpWritePtr | gdWebpWriteOpenPtr (const gdWebpAnimWriteOptions *options) |
| Open a WebP animation writer that returns a memory buffer. | |
| int | gdWebpWriteAddImage (gdWebpWritePtr webp, gdImagePtr image, int durationMs) |
| Add an image to a WebP animation writer. | |
| void | gdWebpWriteClose (gdWebpWritePtr webp) |
| Finish, write, and close a WebP animation writer. | |
| void * | gdWebpWritePtrFinish (gdWebpWritePtr webp, int *size) |
| Finish a WebP memory writer and return the encoded buffer. | |
WebP image reading, writing and animations support.
WebP support reads still images as truecolor gd images and provides animation readers for raw frame rectangles or coalesced full-canvas images. WebP writers accept truecolor gd images; single-image pointer writers return buffers that must be freed with gdFree(), and animation writers are closed with gdWebpWriteClose() or gdWebpWritePtrFinish().
| #define gdWebpLossless 101 |
Lossless WebP quality threshold.
When the quantization value passed to gdImageWebpEx(), gdImageWebpCtx(), or gdImageWebpPtrEx() is greater than or equal to gdWebpLossless, the image is written in lossless WebP format.
| typedef struct gdWebpRead* gdWebpReadPtr |
Opaque WebP animation reader handle.
Handles returned by gdWebpReadOpen(), gdWebpReadOpenCtx(), or gdWebpReadOpenPtr() must be closed with gdWebpReadClose().
| typedef struct gdWebpWrite* gdWebpWritePtr |
Opaque WebP animation writer handle.
Handles returned by gdWebpWriteOpen() or gdWebpWriteOpenCtx() must be closed with gdWebpWriteClose(). Handles returned by gdWebpWriteOpenPtr() must be finished with gdWebpWritePtrFinish().
| anonymous enum |
| anonymous enum |
| gdImagePtr gdImageCreateFromWebp | ( | FILE * | inFile | ) |
Create a truecolor image from a WebP stdio file.
gdImageCreateFromWebp() does not close inFile. The returned image is caller-owned and must be destroyed with gdImageDestroy.
| inFile | Pointer to the input FILE stream. |
| gdImagePtr gdImageCreateFromWebpCtx | ( | gdIOCtxPtr | infile | ) |
Create a truecolor image from WebP data read through a gdIOCtx.
gdImageCreateFromWebpCtx() does not close infile. The returned image is caller-owned and must be destroyed with gdImageDestroy.
| infile | Pointer to the gdIOCtx input context. |
| gdImagePtr gdImageCreateFromWebpPtr | ( | int | size, |
| void * | data | ||
| ) |
Create a truecolor image from a WebP memory buffer.
The data buffer is borrowed for the duration of the call. The returned image is caller-owned and must be destroyed with gdImageDestroy.
| size | Size of the WebP memory buffer in bytes. |
| data | Pointer to the WebP memory buffer. |
| void gdImageWebp | ( | gdImagePtr | im, |
| FILE * | outFile | ||
| ) |
Write an image as WebP data to a stdio file with default quality.
gdImageWebp() does not close outFile. The image is borrowed for the duration of the call and must be a truecolor image.
| im | The image to write. |
| outFile | Pointer to the output FILE stream. |
| void gdImageWebpCtx | ( | gdImagePtr | im, |
| gdIOCtxPtr | outfile, | ||
| int | quantization | ||
| ) |
Write an image as WebP data to a gdIOCtx with a quality setting.
gdImageWebpCtx() does not close outfile. The image is borrowed for the duration of the call and must be a truecolor image.
| im | The image to write. |
| outfile | Pointer to the gdIOCtx output context. |
| quantization | WebP quality: -1 for default, 0-100 for lossy, or gdWebpLossless for lossless. |
| int gdImageWebpCtxWithOptions | ( | gdImagePtr | im, |
| gdIOCtxPtr | outfile, | ||
| const gdWebpWriteOptions * | options | ||
| ) |
Write an image as WebP data to a gdIOCtx using write options.
gdImageWebpCtxWithOptions() does not close outfile. The image is borrowed for the duration of the call and must be a truecolor image.
| im | The image to write. |
| outfile | Pointer to the gdIOCtx output context. |
| options | Pointer to WebP write options, or NULL for defaults. |
| void gdImageWebpEx | ( | gdImagePtr | im, |
| FILE * | outFile, | ||
| int | quantization | ||
| ) |
Write an image as WebP data to a stdio file with a quality setting.
gdImageWebpEx() does not close outFile. The image is borrowed for the duration of the call and must be a truecolor image.
| im | The image to write. |
| outFile | Pointer to the output FILE stream. |
| quantization | WebP quality: -1 for default, 0-100 for lossy, or gdWebpLossless for lossless. |
| void * gdImageWebpPtr | ( | gdImagePtr | im, |
| int * | size | ||
| ) |
Write an image as WebP data to a newly allocated memory buffer.
The image is borrowed for the duration of the call and must be a truecolor image. The returned buffer is caller-owned and must be freed with gdFree().
| im | The image to write. |
| size | Pointer to an integer that receives the returned buffer size. |
| void * gdImageWebpPtrEx | ( | gdImagePtr | im, |
| int * | size, | ||
| int | quantization | ||
| ) |
Write an image as WebP data to a newly allocated memory buffer with a quality setting.
The image is borrowed for the duration of the call and must be a truecolor image. The returned buffer is caller-owned and must be freed with gdFree().
| im | The image to write. |
| size | Pointer to an integer that receives the returned buffer size. |
| quantization | WebP quality: -1 for default, 0-100 for lossy, or gdWebpLossless for lossless. |
| void * gdImageWebpPtrWithOptions | ( | gdImagePtr | im, |
| int * | size, | ||
| const gdWebpWriteOptions * | options | ||
| ) |
Write an image as WebP data to a newly allocated memory buffer using write options.
The image is borrowed for the duration of the call and must be a truecolor image. The returned buffer is caller-owned and must be freed with gdFree().
| im | The image to write. |
| size | Pointer to an integer that receives the returned buffer size. |
| options | Pointer to WebP write options, or NULL for defaults. |
| int gdImageWebpWithOptions | ( | gdImagePtr | im, |
| FILE * | outFile, | ||
| const gdWebpWriteOptions * | options | ||
| ) |
Write an image as WebP data to a stdio file using write options.
gdImageWebpWithOptions() does not close outFile. The image is borrowed for the duration of the call and must be a truecolor image.
| im | The image to write. |
| outFile | Pointer to the output FILE stream. |
| options | Pointer to WebP write options, or NULL for defaults. |
| void gdWebpAnimWriteOptionsInit | ( | gdWebpAnimWriteOptions * | options | ) |
Initialize WebP multi-image/animation write options with gd defaults.
The default writer infers the canvas size from the first frame, writes lossy WebP with libwebp's default animation settings, and uses loopCount 0 for infinite looping.
| options | Pointer to the write options structure to initialize. |
| int gdWebpIsAnimated | ( | FILE * | fd | ) |
Test whether a WebP stdio file contains animation.
The stream position is restored before returning when possible. gdWebpIsAnimated() does not close fd.
| fd | Pointer to the input FILE stream. |
| int gdWebpIsAnimatedCtx | ( | gdIOCtxPtr | in | ) |
Test whether a seekable gdIOCtx contains animated WebP data.
The context position is restored before returning when possible. gdWebpIsAnimatedCtx() does not close in.
| in | Pointer to the gdIOCtx input context. |
| int gdWebpIsAnimatedPtr | ( | int | size, |
| void * | data | ||
| ) |
Test whether a WebP memory buffer contains animation.
The data buffer is borrowed for the duration of the call.
| size | Size of the WebP memory buffer in bytes. |
| data | Pointer to the WebP memory buffer. |
| void gdWebpReadClose | ( | gdWebpReadPtr | webp | ) |
Close a WebP animation reader.
| webp | WebP reader handle to close, or NULL. |
| int gdWebpReadGetInfo | ( | gdWebpReadPtr | webp, |
| gdWebpInfo * | info | ||
| ) |
Get WebP container information from a WebP reader.
| webp | WebP reader handle. |
| info | Pointer to a gdWebpInfo structure to receive container information. |
| int gdWebpReadGetMetadata | ( | gdWebpReadPtr | webp, |
| gdImageMetadata * | metadata | ||
| ) |
Extract opaque EXIF, XMP, and ICC metadata from a WebP reader.
| webp | The WebP reader. |
| metadata | Metadata object to populate. |
| int gdWebpReadNextFrame | ( | gdWebpReadPtr | webp, |
| gdWebpFrameInfo * | info, | ||
| gdImagePtr * | frame | ||
| ) |
Read the next raw WebP animation frame rectangle.
When frame is not NULL and the function returns 1, *frame receives a caller-owned truecolor image that must be destroyed with gdImageDestroy. Passing NULL for frame advances the reader without returning the image.
| webp | WebP reader handle opened with raw-frame mode. |
| info | Pointer to a gdWebpFrameInfo structure to receive frame information, or NULL. |
| frame | Pointer to receive the caller-owned frame image, or NULL. |
| int gdWebpReadNextImage | ( | gdWebpReadPtr | webp, |
| gdWebpFrameInfo * | info, | ||
| gdImagePtr * | image | ||
| ) |
Read the next coalesced WebP animation image.
When image is not NULL and the function returns 1, *image receives a caller-owned truecolor full-canvas image that must be destroyed with gdImageDestroy. Passing NULL for image advances the reader without returning the image.
| webp | WebP reader handle. |
| info | Pointer to a gdWebpFrameInfo structure to receive frame information, or NULL. |
| image | Pointer to receive the caller-owned full-canvas image, or NULL. |
| gdWebpReadPtr gdWebpReadOpen | ( | FILE * | fd, |
| const gdWebpReadOptions * | options | ||
| ) |
Open a WebP animation reader from a stdio file.
gdWebpReadOpen() reads the WebP data into the reader and does not close fd. Pass NULL for options to use gd defaults. The returned handle must be closed with gdWebpReadClose().
| fd | Pointer to the input FILE stream. |
| options | Pointer to read options, or NULL for defaults. |
| gdWebpReadPtr gdWebpReadOpenCtx | ( | gdIOCtxPtr | in, |
| const gdWebpReadOptions * | options | ||
| ) |
Open a WebP animation reader from a gdIOCtx.
gdWebpReadOpenCtx() reads the WebP data into the reader and does not close in. Pass NULL for options to use gd defaults. The returned handle must be closed with gdWebpReadClose().
| in | Pointer to the gdIOCtx input context. |
| options | Pointer to read options, or NULL for defaults. |
| gdWebpReadPtr gdWebpReadOpenPtr | ( | int | size, |
| void * | data, | ||
| const gdWebpReadOptions * | options | ||
| ) |
Open a WebP animation reader from a memory buffer.
The data buffer is borrowed for the duration of the call. The returned handle owns its copy of the WebP data and must be closed with gdWebpReadClose(). Pass NULL for options to use gd defaults.
| size | Size of the WebP memory buffer in bytes. |
| data | Pointer to the WebP memory buffer. |
| options | Pointer to read options, or NULL for defaults. |
| void gdWebpReadOptionsInit | ( | gdWebpReadOptions * | options | ) |
Initialize WebP multi-image/animation read options with gd defaults.
The default reader mode is coalesced, so gdWebpReadNextImage() returns full-canvas rendered images. Set gdWebpReadOptions::coalesced to zero before opening the reader to read raw frame rectangles with gdWebpReadNextFrame().
| options | Pointer to the read options structure to initialize. |
| int gdWebpWriteAddImage | ( | gdWebpWritePtr | webp, |
| gdImagePtr | image, | ||
| int | durationMs | ||
| ) |
Add an image to a WebP animation writer.
The image is borrowed for the duration of the call and remains owned by the caller. All frames must match the writer canvas size.
| webp | WebP writer handle. |
| image | Image to add as the next frame. |
| durationMs | Frame duration in milliseconds. |
| void gdWebpWriteClose | ( | gdWebpWritePtr | webp | ) |
Finish, write, and close a WebP animation writer.
Use this for handles returned by gdWebpWriteOpen() or gdWebpWriteOpenCtx(). For memory writers returned by gdWebpWriteOpenPtr(), use gdWebpWritePtrFinish().
| webp | WebP writer handle to finish and close, or NULL. |
| gdWebpWritePtr gdWebpWriteOpen | ( | FILE * | outFile, |
| const gdWebpAnimWriteOptions * | options | ||
| ) |
Open a WebP animation writer for a stdio file.
gdWebpWriteOpen() does not close outFile. The returned handle must be closed with gdWebpWriteClose(), which assembles and writes the animation.
| outFile | Pointer to the output FILE stream. |
| options | Pointer to write options, or NULL for defaults. |
| gdWebpWritePtr gdWebpWriteOpenCtx | ( | gdIOCtxPtr | out, |
| const gdWebpAnimWriteOptions * | options | ||
| ) |
Open a WebP animation writer for a gdIOCtx.
The output context is borrowed and is not closed by gdWebpWriteClose(). The returned handle must be closed with gdWebpWriteClose(), which assembles and writes the animation.
| out | Pointer to the gdIOCtx output context. |
| options | Pointer to write options, or NULL for defaults. |
| gdWebpWritePtr gdWebpWriteOpenPtr | ( | const gdWebpAnimWriteOptions * | options | ) |
Open a WebP animation writer that returns a memory buffer.
The returned handle must be finished with gdWebpWritePtrFinish().
| options | Pointer to write options, or NULL for defaults. |
| void gdWebpWriteOptionsInit | ( | gdWebpWriteOptions * | options | ) |
Initialize WebP still-image write options with gd defaults.
The default writer uses libwebp's default quality and writes no metadata.
| options | Pointer to the write options structure to initialize. |
| void * gdWebpWritePtrFinish | ( | gdWebpWritePtr | webp, |
| int * | size | ||
| ) |
Finish a WebP memory writer and return the encoded buffer.
This closes webp whether encoding succeeds or fails. The returned buffer is caller-owned and must be freed with gdFree().
| webp | WebP memory writer handle returned by gdWebpWriteOpenPtr(). |
| size | Pointer to an integer that receives the returned buffer size. |