How Convert JPG to WEBP with PHP
Friday 15th, Apr, 2022 | #
What Google represents in the world of search engines is JPEG, also called JPG, in the presentation of photographs and large images on the World Wide Web. A quarter of a century or so after its release, it is hard to imagine a website without this image format. Its biggest advantage, compared to formats such as PNG (also very widespread but used mainly for small images and graphics such as logos or icons) is undoubtedly that JPEG saves storage space thanks to its lossy compression.
In this crucial detail, WebP also proves to be more efficient and flexible: on the one hand, Google's format offers, in addition to a lossy compression method, a lossless one. On the other hand, the storage space savings in WebP-formatted images exceed those of similar JPEG images. The fact that JPEG supports images up to 65,535 x 65,535 pixels, while WebP is limited to 16,383 x 16,383 pixels is not relevant in view of the field of application (web).
Convert any image jpg to webp is very simple with PHP
<? $imagen = imagecreatefromjpeg($img_url); //imagewebp(resource $image, mixed $to = null, int $quality = 80): bool imagewebp($img, 'image.webp', 85); ?>
Why do jpegs save as WebP?
Google claims that webp reduces the size of images significantly in comparison to png and jpg. It reduces the file size in comparison to png images by up to 26%, and by up to 34% in comparison to jpg images. This can greatly help your site to improve CORE VITALS
