PHP imagecreatefromgif动画+颜色

时间:2016-11-10 19:09:32

标签: php animation php-gd

我正在尝试用PHP创建一个图像。

使用PNG,效果非常好(字体颜色有效!)。

但如果我使用GIF,字体就不会得到颜色(总是白色)。

我用于背景的GIF图像不是动画!

这是它在PNG(字体颜色)中的工作原理:

<?php
    $zeile1 = @file_get_contents('zeile1.txt');
    $zeile1_title = @file_get_contents('zeile1_title.txt');

    $image = imagecreatefrompng("bg_text.png");
    imagesavealpha($image, true);
    imagealphablending($image, true);
    $finalImage = imagecreatetruecolor(391,300);

    $font = '../banner1/arial.ttf';
    $color = imagecolorallocate($finalImage, 0, 0, 0);

    $font_title = '../banner1/arialbd.ttf';
    $color_title = imagecolorallocate($finalImage, 255, 0, 126);

    imagettftext($image, 15, 0, 2, 130, $color, $font, $zeile1);

    imagettftext($image, 25, 0, 2, 130, $color_title, $font_title, $zeile1_title);

    header('Content-type: image/png');
    imagepng($image);
?>

但现在我想要一个动画gif作为背景:

<?php
    $zeile1 = @file_get_contents('zeile1.txt');
    $zeile1_title = @file_get_contents('zeile1_title.txt');

    $image = imagecreatefromgif("bg_text.gif");
    imagesavealpha($image, true);
    imagealphablending($image, true);
    $finalImage = imagecreatetruecolor(391,300);

    $font = '../banner1/arial.ttf';
    $color = imagecolorallocate($finalImage, 0, 0, 0);

    $font_title = '../banner1/arialbd.ttf';
    $color_title = imagecolorallocate($finalImage, 255, 0, 126);

    imagettftext($image, 15, 0, 2, 130, $color, $font, $zeile1);

    imagettftext($image, 25, 0, 2, 130, $color_title, $font_title, $zeile1_title);

    header('Content-type: image/gif');
    imagegif($image);
?>

现在文字只有白色,标题文字不显示+图像没有动画。

我希望你明白我的意思,因为我的英语不好:/

0 个答案:

没有答案
相关问题