Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用GD编辑动画GIF图像?_Php_Image Processing_Gd - Fatal编程技术网

Php 如何使用GD编辑动画GIF图像?

Php 如何使用GD编辑动画GIF图像?,php,image-processing,gd,Php,Image Processing,Gd,我使用此函数更新动画GIF图像,但GD是否将其渲染为静态 function draw_image () { $img=imagecreatefromgif('images/moni.gif'); $text='test'; $lastpayout='test'; $colors['name'] = imagecolorallocate($img, 999, 000, 156); ImageTTFText($img, 9, 0, 20, 235,

我使用此函数更新动画GIF图像,但GD是否将其渲染为静态

function draw_image ()

  {

    $img=imagecreatefromgif('images/moni.gif');

    $text='test';
    $lastpayout='test'; 
    $colors['name'] = imagecolorallocate($img, 999, 000, 156);
    ImageTTFText($img, 9, 0, 20, 235, $colors['name'], "images/impact.ttf", $text);
    ImageTTFText($img, 9, 0, 20, 250, $colors['name'],"images/tahoma.ttf",$lastpayout);
    ImageTTFText($img, 10, 0, 15, 270, $colors['name'], "images/tahoma.ttf", $text);
    header("Content-type: image/gif");
    imagegif($img);
  }

echo  draw_image ();

此函数用于将动画GIF转换为静态GIF。有人能帮我吗?

GD不支持动画GIF。您可以尝试imagick。

如果您可以使用:


我现在不知道这是否与您的问题有关,但是
imagecolorallocate
使用0-255的RGB值。我认为OP指的是GIF的第一帧“静态”,而不是白噪声。我使用此函数加载GIF:/但是steel不起作用。您会遇到什么错误?什么不起作用?它起作用:
注意:GIF支持在版本1.6中从GD库中删除,并在版本2.0.28中重新添加。此功能在这些版本之间不可用。
@Robin关键字已设置动画。您需要安装imagick PHP扩展。在大多数Linux发行版上应该很容易:
apt get install php5 imagick
$gif = new Imagick('full/path/to/your/image.gif');

$draw = new ImagickDraw();    
$draw->setFont('full/path/to/your/font.ttf');
$draw->setFontSize(30);
$draw->setFillColor('white');

// put text on each frame
foreach($gif as $frame){
  $gif->annotateImage($draw, $x = 10, $y = 45, $angle = 0, 'Your text');         
}    

header('Content-Type: image/gif');
print $gif->getImagesBlob();