как сделать прозрачный фон или хотябы белый для изображения webp?
$gd_info = gd_info();
if($gd_info['WebP Support']) {
$image_new_webp = 'cache/webp/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '.webp';
if (is_file(DIR_IMAGE . $image_new) && (!is_file(DIR_IMAGE . $image_new_webp) || (filemtime(DIR_IMAGE . $image_new) > filemtime(DIR_IMAGE . $image_new_webp)))) {
$path = '';
$directories = explode('/', dirname($image_new_webp));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!is_dir(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
$extension = strtolower($extension);
if ($extension == 'gif') {
$img = imagecreatefromgif(DIR_IMAGE.$image_new);
} elseif ($extension == 'png') {
$img = imagecreatefrompng(DIR_IMAGE.$image_new);
} elseif ($extension == 'jpeg' || $extension == 'jpg') {
$img = imagecreatefromjpeg(DIR_IMAGE.$image_new);
} else {
$img = '';
}
if($img) {
imagepalettetotruecolor($img);
imagewebp($img, DIR_IMAGE.$image_new_webp);
imagedestroy($img);
}
}
if(is_file(DIR_IMAGE . $image_new_webp)) {
if(stripos($this->request->server['REQUEST_URI'], 'admin') === false && isset($this->request->server['HTTP_ACCEPT']) && strpos($this->request->server['HTTP_ACCEPT'], 'image/webp') !== false) {
$image_new = $image_new_webp;
}
}
}