Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $pngimg = imagecreatefrompng($file);
- $w = imagesx($pngimg);
- $h = imagesy($pngimg);;
- $im = imagecreatetruecolor ($w, $h);
- imageAlphaBlending($im, false);
- imageSaveAlpha($im, true);
- $trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
- imagefilledrectangle($im, 0, 0, $w - 1, $h - 1, $trans);
- imagecopy($im, $pngimg, 0, 0, 0, 0, $w, $h);
- imagewebp($im, str_replace('png', 'webp', $file), 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement