Read and write WebP images.
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. |
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.
gdImageCreateFromWebpPtr creates an image from WebP data already in memory.
gdImageCreateFromWebpCtx reads its data via the function pointers in a gdIOCtx structure.
infile | The input FILE pointer. |
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.
void gdImageWebpCtx ( gdImagePtr im, gdIOCtx * outfile, int quality )
Write the image as WebP data via a gdIOCtx. See gdImageWebpEx for more details.
im | The image to write. |
outfile | The output sink. |
quality | Image quality. |
Nothing.
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.
gdImageWebpCtx stores the image using a gdIOCtx struct.
gdImageWebpPtrEx stores the image to RAM.
im | The image to save. |
outFile | The FILE pointer to write to. |
quality | Compression quality (0-100). |
Nothing.
void gdImageWebp ( gdImagePtr im, FILE * outFile )
Variant of gdImageWebpEx which uses the default quality (-1).
im | The image to save |
outFile | The FILE pointer to write to. |
Nothing.
void * gdImageWebpPtr ( gdImagePtr im, int * size )
See gdImageWebpEx.
void * gdImageWebpPtrEx ( gdImagePtr im, int * size, int quality )
See gdImageWebpEx.
gdImageCreateFromWebp is called to load truecolor images from WebP format files.
gdImagePtr gdImageCreateFromWebp ( FILE * inFile )
See gdImageCreateFromWebp.
gdImagePtr gdImageCreateFromWebpPtr ( int size, void * data )
See gdImageCreateFromWebp.
gdImagePtr gdImageCreateFromWebpCtx ( gdIOCtx * infile )
Write the image as WebP data via a gdIOCtx.
void gdImageWebpCtx ( gdImagePtr im, gdIOCtx * outfile, int quality )
gdImageWebpEx outputs the specified image to the specified file in WebP format.
void gdImageWebpEx ( gdImagePtr im, FILE * outFile, int quality )
Variant of gdImageWebpEx which uses the default quality (-1).
void gdImageWebp ( gdImagePtr im, FILE * outFile )
See gdImageWebpEx.
void * gdImageWebpPtr ( gdImagePtr im, int * size )
See gdImageWebpEx.
void * gdImageWebpPtrEx ( gdImagePtr im, int * size, int quality )
gdImageDestroy is used to free the memory associated with an image.
void gdImageDestroy ( gdImagePtr im )