LibGd 2.4.0-dev
GD Graphics library
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
WebP

WebP image reading, writing and animations support. More...

Collaboration diagram for WebP:

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.
 

Detailed Description

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().

FILE *in, *out;
gdWebpFrameInfo frameInfo;
gdImagePtr image;
int result;
in = fopen("input.webp", "rb");
if (in == NULL) {
fprintf(stderr, "cannot open input.webp\n");
exit(1);
}
reader = gdWebpReadOpen(in, NULL);
fclose(in);
if (reader == NULL || !gdWebpReadGetInfo(reader, &info)) {
fprintf(stderr, "cannot read WebP\n");
if (reader != NULL) {
gdWebpReadClose(reader);
}
exit(1);
}
options.canvasWidth = info.width;
options.canvasHeight = info.height;
options.loopCount = info.loopCount;
options.backgroundColor = info.backgroundColor;
out = fopen("output.webp", "wb");
if (out == NULL) {
gdWebpReadClose(reader);
exit(1);
}
writer = gdWebpWriteOpen(out, &options);
if (writer == NULL) {
fclose(out);
gdWebpReadClose(reader);
exit(1);
}
while ((result = gdWebpReadNextImage(reader, &frameInfo, &image)) == 1) {
if (!gdWebpWriteAddImage(writer, image, frameInfo.duration)) {
gdImageDestroy(image);
fclose(out);
gdWebpReadClose(reader);
exit(1);
}
gdImageDestroy(image);
}
fclose(out);
void gdWebpAnimWriteOptionsInit(gdWebpAnimWriteOptions *options)
Initialize WebP multi-image/animation write options with gd defaults.
Definition gd_webp.c:1243
struct gdWebpWrite * gdWebpWritePtr
Opaque WebP animation writer handle.
Definition gd.h:2169
int gdWebpWriteAddImage(gdWebpWritePtr webp, gdImagePtr image, int durationMs)
Add an image to a WebP animation writer.
Definition gd_webp.c:1467
void gdWebpReadClose(gdWebpReadPtr webp)
Close a WebP animation reader.
Definition gd_webp.c:1394
#define gdWebpLossless
Lossless WebP quality threshold.
Definition gd.h:5666
struct gdWebpRead * gdWebpReadPtr
Opaque WebP animation reader handle.
Definition gd.h:2160
int gdWebpReadNextImage(gdWebpReadPtr webp, gdWebpFrameInfo *info, gdImagePtr *image)
Read the next coalesced WebP animation image.
Definition gd_webp.c:1429
void gdWebpWriteClose(gdWebpWritePtr webp)
Finish, write, and close a WebP animation writer.
Definition gd_webp.c:1476
gdWebpReadPtr gdWebpReadOpen(FILE *fd, const gdWebpReadOptions *options)
Open a WebP animation reader from a stdio file.
Definition gd_webp.c:1367
int gdWebpReadGetInfo(gdWebpReadPtr webp, gdWebpInfo *info)
Get WebP container information from a WebP reader.
Definition gd_webp.c:1400
gdWebpWritePtr gdWebpWriteOpen(FILE *outFile, const gdWebpAnimWriteOptions *options)
Open a WebP animation writer for a stdio file.
Definition gd_webp.c:1441
WebP animation writer options.
Definition gd.h:2219
int quality
Definition gd.h:2224
WebP animation frame information.
Definition gd.h:2187
int duration
Definition gd.h:2193
WebP container information.
Definition gd.h:2174
int height
Definition gd.h:2176
int width
Definition gd.h:2175

Macro Definition Documentation

◆ gdWebpLossless

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

◆ gdWebpReadPtr

typedef struct gdWebpRead* gdWebpReadPtr

Opaque WebP animation reader handle.

Handles returned by gdWebpReadOpen(), gdWebpReadOpenCtx(), or gdWebpReadOpenPtr() must be closed with gdWebpReadClose().

◆ gdWebpWritePtr

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().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

WebP frame disposal methods.

Enumerator
gdWebpDisposeNone 

Do not dispose the frame after display.

gdWebpDisposeBackground 

Clear the frame rectangle to the background after display.

◆ anonymous enum

anonymous enum

WebP frame blend methods.

Enumerator
gdWebpBlendAlpha 

Blend the frame using alpha compositing.

gdWebpBlendNone 

Replace the frame rectangle without alpha blending.

Function Documentation

◆ gdImageCreateFromWebp()

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.

Parameters
inFilePointer to the input FILE stream.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageCreateFromWebpCtx()

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.

Parameters
infilePointer to the gdIOCtx input context.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageCreateFromWebpPtr()

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.

Parameters
sizeSize of the WebP memory buffer in bytes.
dataPointer to the WebP memory buffer.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageWebp()

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.

Parameters
imThe image to write.
outFilePointer to the output FILE stream.

◆ gdImageWebpCtx()

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.

Parameters
imThe image to write.
outfilePointer to the gdIOCtx output context.
quantizationWebP quality: -1 for default, 0-100 for lossy, or gdWebpLossless for lossless.

◆ gdImageWebpCtxWithOptions()

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.

Parameters
imThe image to write.
outfilePointer to the gdIOCtx output context.
optionsPointer to WebP write options, or NULL for defaults.
Returns
Returns 0 on success, or 1 on failure.

◆ gdImageWebpEx()

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.

Parameters
imThe image to write.
outFilePointer to the output FILE stream.
quantizationWebP quality: -1 for default, 0-100 for lossy, or gdWebpLossless for lossless.

◆ gdImageWebpPtr()

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().

Parameters
imThe image to write.
sizePointer to an integer that receives the returned buffer size.
Returns
Returns a pointer to the newly allocated WebP buffer, or NULL on failure.

◆ gdImageWebpPtrEx()

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().

Parameters
imThe image to write.
sizePointer to an integer that receives the returned buffer size.
quantizationWebP quality: -1 for default, 0-100 for lossy, or gdWebpLossless for lossless.
Returns
Returns a pointer to the newly allocated WebP buffer, or NULL on failure.

◆ gdImageWebpPtrWithOptions()

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().

Parameters
imThe image to write.
sizePointer to an integer that receives the returned buffer size.
optionsPointer to WebP write options, or NULL for defaults.
Returns
Returns a pointer to the newly allocated WebP buffer, or NULL on failure.

◆ gdImageWebpWithOptions()

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.

Parameters
imThe image to write.
outFilePointer to the output FILE stream.
optionsPointer to WebP write options, or NULL for defaults.
Returns
Returns 0 on success, or 1 on failure.

◆ gdWebpAnimWriteOptionsInit()

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.

Parameters
optionsPointer to the write options structure to initialize.

◆ gdWebpIsAnimated()

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.

Parameters
fdPointer to the input FILE stream.
Returns
Returns 1 for animated WebP, 0 for still WebP, or -1 on error.

◆ gdWebpIsAnimatedCtx()

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.

Parameters
inPointer to the gdIOCtx input context.
Returns
Returns 1 for animated WebP, 0 for still WebP, or -1 on error.

◆ gdWebpIsAnimatedPtr()

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.

Parameters
sizeSize of the WebP memory buffer in bytes.
dataPointer to the WebP memory buffer.
Returns
Returns 1 for animated WebP, 0 for still WebP, or -1 on error.

◆ gdWebpReadClose()

void gdWebpReadClose ( gdWebpReadPtr  webp)

Close a WebP animation reader.

Parameters
webpWebP reader handle to close, or NULL.

◆ gdWebpReadGetInfo()

int gdWebpReadGetInfo ( gdWebpReadPtr  webp,
gdWebpInfo info 
)

Get WebP container information from a WebP reader.

Parameters
webpWebP reader handle.
infoPointer to a gdWebpInfo structure to receive container information.
Returns
Returns 1 on success, or 0 on failure.

◆ gdWebpReadGetMetadata()

int gdWebpReadGetMetadata ( gdWebpReadPtr  webp,
gdImageMetadata *  metadata 
)

Extract opaque EXIF, XMP, and ICC metadata from a WebP reader.

Parameters
webpThe WebP reader.
metadataMetadata object to populate.
Returns
GD_META_OK on success, or a GD_META_ERR_* value on failure.

◆ gdWebpReadNextFrame()

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.

Parameters
webpWebP reader handle opened with raw-frame mode.
infoPointer to a gdWebpFrameInfo structure to receive frame information, or NULL.
framePointer to receive the caller-owned frame image, or NULL.
Returns
Returns 1 when a frame is read, 0 at end of animation, or -1 on error.

◆ gdWebpReadNextImage()

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.

Parameters
webpWebP reader handle.
infoPointer to a gdWebpFrameInfo structure to receive frame information, or NULL.
imagePointer to receive the caller-owned full-canvas image, or NULL.
Returns
Returns 1 when an image is read, 0 at end of animation, or -1 on error.

◆ gdWebpReadOpen()

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().

Parameters
fdPointer to the input FILE stream.
optionsPointer to read options, or NULL for defaults.
Returns
Returns a WebP reader handle on success, or NULL on failure.

◆ gdWebpReadOpenCtx()

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().

Parameters
inPointer to the gdIOCtx input context.
optionsPointer to read options, or NULL for defaults.
Returns
Returns a WebP reader handle on success, or NULL on failure.

◆ gdWebpReadOpenPtr()

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.

Parameters
sizeSize of the WebP memory buffer in bytes.
dataPointer to the WebP memory buffer.
optionsPointer to read options, or NULL for defaults.
Returns
Returns a WebP reader handle on success, or NULL on failure.

◆ gdWebpReadOptionsInit()

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().

Parameters
optionsPointer to the read options structure to initialize.

◆ gdWebpWriteAddImage()

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.

Parameters
webpWebP writer handle.
imageImage to add as the next frame.
durationMsFrame duration in milliseconds.
Returns
Returns 1 on success, or 0 on failure.

◆ gdWebpWriteClose()

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().

Parameters
webpWebP writer handle to finish and close, or NULL.

◆ gdWebpWriteOpen()

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.

Parameters
outFilePointer to the output FILE stream.
optionsPointer to write options, or NULL for defaults.
Returns
Returns a WebP writer handle on success, or NULL on failure.

◆ gdWebpWriteOpenCtx()

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.

Parameters
outPointer to the gdIOCtx output context.
optionsPointer to write options, or NULL for defaults.
Returns
Returns a WebP writer handle on success, or NULL on failure.

◆ gdWebpWriteOpenPtr()

gdWebpWritePtr gdWebpWriteOpenPtr ( const gdWebpAnimWriteOptions options)

Open a WebP animation writer that returns a memory buffer.

The returned handle must be finished with gdWebpWritePtrFinish().

Parameters
optionsPointer to write options, or NULL for defaults.
Returns
Returns a WebP memory writer handle on success, or NULL on failure.

◆ gdWebpWriteOptionsInit()

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.

Parameters
optionsPointer to the write options structure to initialize.

◆ gdWebpWritePtrFinish()

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().

Parameters
webpWebP memory writer handle returned by gdWebpWriteOpenPtr().
sizePointer to an integer that receives the returned buffer size.
Returns
Returns a pointer to the newly allocated WebP buffer, or NULL on failure.