PDA

View Full Version : I want to create animated gifs with php code


rush4hire
10-02-2005, 08:03 AM
I found this cool script.
From here.
http://www.php.net/manual/en/ref.image.php
It will produce a gif of stick men drawn by this code. The gif will appear in the folderwhere you have the script you executed.

<?php
// 0
$img = imagecreatetruecolor(300,300);
$bgcol = imagecolorallocate($img,255,255,255);
$hatcol = imagecolorallocate($img,rand(128,255),rand(128,255),rand(128,255));
$headcol = imagecolorallocate($img,255,225,205);
$bodycol = imagecolorallocate($img,0,0,0);
$eyecol = imagecolorallocate($img,rand(100,200),rand(0,128),rand(128,255));
$mouthcol = imagecolorallocate($img,rand(128,255),0,0);
imagefill($img,0,0,$bgcol);
// 1
imagefilledellipse($img,60,71,50,50,$headcol);
imagefilledpolygon($img,array(30,53,60,23,90,53),3,$hatcol);
imagesetthickness($img,5);
imageline($img,60,97,60,201,$bodycol);
imagesetthickness($img,1);
imagefilledellipse($img,50,65,7,5,$eyecol);
imagefilledellipse($img,70,65,7,5,$eyecol);
imagesetthickness($img,8);
imageline($img,60,201,10,251,$bodycol);
imageline($img,60,201,110,251,$bodycol);
imageline($img,60,136,10,186,$bodycol);
imageline($img,60,136,110,186,$bodycol);
imagesetthickness($img,3);
imageline($img,50,80,60,90,$mouthcol);
imageline($img,60,90,70,80,$mouthcol);
// 2
$hatcol = imagecolorallocate($img,rand(128,255),rand(128,255),rand(128,255));
$headcol = imagecolorallocate($img,255,225,205);
$bodycol = imagecolorallocate($img,0,0,0);
$eyecol = imagecolorallocate($img,rand(100,200),rand(0,128),rand(128,255));
$mouthcol = imagecolorallocate($img,rand(128,255),0,0);
imagefilledellipse($img,200,71,50,50,$headcol);
imagefilledpolygon($img,array(170,53,200,23,230,53),3,$hatcol);
imagesetthickness($img,5);
imageline($img,200,97,200,201,$bodycol);
imagesetthickness($img,1);
imagefilledellipse($img,190,65,7,5,$eyecol);
imagefilledellipse($img,210,65,7,5,$eyecol);
imagesetthickness($img,8);
imageline($img,200,201,150,251,$bodycol);
imageline($img,200,201,250,251,$bodycol);
imageline($img,200,136,150,186,$bodycol);
imageline($img,200,136,250,186,$bodycol);
imagesetthickness($img,3);
imageline($img,190,80,200,90,$mouthcol);
imageline($img,200,90,210,80,$mouthcol);
// 3
imagestring($img,2,223,283,"(C) Shadikka",$bodycol);
imagesetthickness($img,1);
imagerectangle($img,0,0,299,299,$bodycol);
header("Content-type: image/png");
imagegif($img,'something.gif');
imagedestroy($img);
?>

I want to create an animaged gif.
I can parse a warcraft replay and get the coordinants every action in the game. Now I want to draw a gif with code that will simulate the play in the game.

Don't wanna explain all that now. But if anyone knows how to use php image functions to create an animated gif I would really appriciate it.

Here's a random example of the output my current php replay parser produces.
http://e.domaindlx.com/rush4hire/w3g/brrj_kalotxPINK2_522171.htm

Thanks. :)

rush4hire
10-02-2005, 09:09 AM
Ok so far I found this.
http://us3.php.net/manual/en/function.imagegif.php#54419
I have to install imagemagic

And this.
http://ffmpeg-php.sourceforge.net/

And that would take some setting up too.

rush4hire
10-06-2005, 09:51 PM
nvm

I'm just gonna make a lil movie. It will be neat !! :P

Can't wait to get started. My project after I get this database stuff up and running.

rush4hire
04-13-2006, 05:24 AM
Wow still no one has replied to this topic.

It's just not possible to do anything with gifs or flash with php code ?

I got some examples here of this replay parser I was talkin about. In these examples, the little gifs are just moved around by javascript.

Just look at http://www.rush4hire.com/
Under replay examples.

I haven't been working on this one for a long time.

ttttt
04-17-2006, 09:22 PM
Try posting in the php forum :thumbsup: