setImageFormat("webp");$img->writeImage("1.webp");" code."/> setImageFormat("webp");$img->writeImage("1.webp");" code.">

Home >Backend Development >PHP Problem >How to convert php jpg to webp

How to convert php jpg to webp

藏色散人
藏色散人Original
2021-09-26 11:26:423464browse

php jpg to webp method: 1. Create a PHP sample file; 2. Execute "$img->setImageFormat("webp");$img->writeImage("1.webp") ;" code is enough.

How to convert php jpg to webp

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer.

How to convert php jpg to webp?

Convert PHP pictures to webp format

Convert picture 1.jpg to 1 .webp, 1.jpg is the real address of the image

The code is as follows:

$img = new \Imagick("1.jpg");
$img->setImageFormat("webp");
$img->writeImage("1.webp");

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to convert php jpg to webp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn