webp with transparency
-
how to keep transparency from PNG to WEBP ?
I use code for thumbnailadd_filter('wp_generate_attachment_metadata', 'custom_webp_thumb'); function custom_webp_thumb($metadata) { // URL $uploads = wp_upload_dir(); // $path_parts = pathinfo($metadata['file']); // for 2018/10 $file = path_join( $uploads['basedir'], $path_parts['dirname'].'/'. $metadata["sizes"]["medium"]["file"] ); // original image file $image = imagecreatefrompng($file); // or imagecreatefromjpeg // imagepalettetotruecolor($image); - not help // imagealphablending($image, false); - not help // imagesavealpha($image, true); - not help // Save the image imagewebp($image, '/home/****/2018/10/'.$metadata["sizes"]["medium"]["file"].'.webp'); // unlink($file); return $metadata; }pictures are obtained with a black and not transparent background
——— PNG with transparency ————- WEBP with Black background —–

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘webp with transparency’ is closed to new replies.