Php 如何使用GD编辑动画GIF图像?
我使用此函数更新动画GIF图像,但GD是否将其渲染为静态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,
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();