bas
Новичок
Прозрачность при уменьшении гифки
Вот например. Не получается никак прозрачная картинка.
Получается черный фон вместо прозрачного.
<?php
$filename = 'test.gif';
$percent = 0.5;
// Content type
header("Content-type: image/gif");
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromgif($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$ct = imagecolortransparent($image);
$color_tran = imagecolorsforindex($image, $ct);
$ct2 = imagecolorexact($image_p, $color_tran['red'], $color_tran['green'], $color_tran['blue']);
imagecolortransparent($image_p, $ct2);
imagegif($image_p);
?>
Что не так?
Вот например. Не получается никак прозрачная картинка.
Получается черный фон вместо прозрачного.
<?php
$filename = 'test.gif';
$percent = 0.5;
// Content type
header("Content-type: image/gif");
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromgif($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$ct = imagecolortransparent($image);
$color_tran = imagecolorsforindex($image, $ct);
$ct2 = imagecolorexact($image_p, $color_tran['red'], $color_tran['green'], $color_tran['blue']);
imagecolortransparent($image_p, $ct2);
imagegif($image_p);
?>
Что не так?