Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert jpg to webp in php

Shulou Source: shulou.com Published: 2022-06-03 09:53:59 11月15日 Update

This article mainly introduces how to convert jpg to webp in php, which has a certain reference value. Interested friends can refer to it. I hope you can learn a lot after reading this article.

Php jpg to webp method: 1, create a PHP sample file; 2, execute "$img- > setImageFormat (" webp "); $img- > writeImage (" 1.webp ");" code can be.

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer.

PHP pictures are converted to webp format

Convert the picture 1.jpg to 1.webpjpjpg is the real address of the picture.

The code is as follows:

$img = new\ Imagick ("1.jpg"); $img- > setImageFormat ("webp"); $img- > writeImage ("1.webp"); Thank you for reading this article carefully. I hope the article "how to transfer jpg to webp in php" shared by the editor will be helpful to you. At the same time, I hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Tags: Articles pictures code value interests at the same time addresses files methods more friends formats environment computers knowledge examples systems editing industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Information Shulou Tech Info vpn MySQL