How do you create .webp
images using PHP?
Modern versions of PHP (>= 5.5.0) can be compiled with WebP
support but from I've seen this isn't common on many web hosts. If compiled with WebP support you can use the built-in imagewebp()
function to create .webp
images.
What are the alternatives for creating .webp
images using PHP? Libraries, APIs other methods?
imagecreatefromjpeg
orimagecreatefrompng
and then just save withimagewebp($im, 'file.webp');
You could also batch convert with convert (imagick) or call a service like Cloudinary: cloudinary.com/documentation/php_image_manipulation (awesome service btw!) – Condorimagefromjpeg
andimagecreatefrompngand
then just write withimagewebp
that should convert the file. You can use Cloudinary, which will do this for you but it's a service, depending on your usage it will have cost. Then using Modernizr to detect support and change your images accordingly (kinda of what you'd do with retina images). One of the perks of using a service is that the image will be created on the fly, no need for you to do the processing. – Condor