9951 explained code solutions for 126 technologies


php-gdHow to save image in webp format


$im = imagecreatetruecolor(400, 300);

$c_black = imageColorAllocate($im, 0,0,0);
$c_green = imageColorAllocate($im, 46,204,64);

imageellipse($im, 200, 150, 100, 100, $c_green);

imagewebp($im, '/tmp/image.webp');ctrl + c
imagecreatetruecolor

creates true color GD image object with specified width & height

imageColorAllocate

creates color object to later use in image

imageellipse

creates ellipse with specified coordinates, radius and border color

imagewebp

saves given gd image in webp format to the specified path

/tmp/image.webp

path to save image to