Answer the question
In order to leave comments, you need to log in
How to make transparency for webp in php?
Good day, I am converting from the format of incoming images to webp, but unfortunately, for some reason, transparency is not saved in webp, although it supports it.
Tell me how to fix the situation?
function createWebpImage2($link,$name){
if(file_exists($link)){
$a = exif_imagetype($link);
switch($a){
case 1:
$source = imagecreatefromgif($link);
break;
case 2:
$source = imagecreatefromjpeg($link);
break;
case 3:
$source = imagecreatefrompng($link);
break;
default: $source=false;
}
}
else{
return false;
}
imagealphablending($source, false);
imagesavealpha($source, true);
imagewebp($source,$name.'.webp');
imagedestroy($source);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question