Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert webP image format to normal ? php

Tags:

php

image

webp

I have an ios and android application. sometime the users upload webP image to my server. the problem is ios can't show this image when it's downloaded from my server.

so I want to check within my php code. if the image is webP format . then i will convert it to png format.

How could i do that using php?

like image 850
david Avatar asked Jun 30 '15 07:06

david


1 Answers

It's late but just for the sake of it. It can be done using PHP only. Without any external tool.

Quoted from PHP.net documentation:

<?php
// Load the WebP file
$im = imagecreatefromwebp('./example.webp');

// Convert it to a jpeg file with 100% quality
imagejpeg($im, './example.jpeg', 100);
imagedestroy($im);
?>

So I assume you can use imagepng() instead of imagejpeg that is in the example.

like image 161
Usama Ejaz Avatar answered Oct 01 '22 00:10

Usama Ejaz