GD! Konwersja obrazu png NA jpeg i ustawienie domyślnej wersji alfa na białej, a nie czarnej
Próbowałem czegoś takiego, ale to sprawia, że tło obrazu jest białe, niekoniecznie Alfa obrazu. Chciałem po prostu przesłać wszystko jako jpg, więc jeśli mogę jakoś "spłaścić" obraz png z niektórymi przezroczystymi, aby domyślnie był po prostu biały, więc mogę go używać jako jpg zamiast. Doceniam każdą pomoc. Dzięki.
$old = imagecreatefrompng($upload); $background = imagecolorallocate($old,255,255,255); imagefill($old, 0, 0, $background); imagealphablending($old, false); imagesavealpha($old, true);
21
1 answers
<?php
$input_file = "test.png";
$output_file = "test.jpg";
$input = imagecreatefrompng($input_file);
$width = imagesx($input);
$height = imagesy($input);
$output = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($output, 255, 255, 255);
imagefilledrectangle($output, 0, 0, $width, $height, $white);
imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
imagejpeg($output, $output_file);
62
Author: Alex Jasmin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-12-16 01:13:49
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-12-16 01:13:49