note 59199 deleted from function.imagegif by danbrown
| From: | danbrown@php.net | Date: | Tue, 09 Jun 2009 13:17:21 +0000 |
| Subject: | note 59199 deleted from function.imagegif by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156603@lists.php.net to get a copy of this message | ||
Note Submitter: cascade at mylifesucks dot de
----
I would rather use gifsicle ( http://www.lcdf.org/gifsicle/ ) instead of convert. It runs
much faster with big animations. I got large animations with over 500 frames rendered where convert
was killed by my system because of memory consumption. And it contains pretty well optimization.
A sample gifsicle usage (not much optimized):
<?
// Sample gifsicle usage to create a scrolling text
$gifsicle = "/usr/local/bin/gifsicle"; # http://www.lcdf.org/gifsicle/
$time = time();
for ($rend_frame = 0; $rend_frame <= 26; $rend_frame++) {
$im = @imagecreatetruecolor(300, 20);
$background = imagecolorallocate($im, 0, 0, 100);
$red = imagecolorallocate($im, 255, 0, 0);
$filename = "/tmp/giftest_".$time."_".str_pad($rend_frame, 10,
"0", STR_PAD_LEFT).".gif";
$framefiles[] = $filename;
imagestring($im, 3, ($rend_frame * 15)-80, 3, "Animation rox", $red);
imagegif($im,$filename);
imagedestroy($im);
};
$outfile = "/tmp/giftest_".$time.".gif";
$cmd = "$gifsicle --loop -O1 --delay 25 /tmp/giftest_".$time."*> $outfile";
exec($cmd, $out, $err);
foreach ($framefiles as $framefile) {
if (file_exists($framefile)) unlink($framefile);
};
header('Content-type: image/gif');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: inline; filename=test.gif');
header('Content-Length: '.@filesize($outfile));
readfile($outfile);
unlink($outfile);
?>
Or get patches from http://hyvatti.iki.fi/~jaakko/sw/ to be able to do it
all inside php...