note 67933 modified in function.imagegif by danbrown

From: Date: Tue, 09 Jun 2009 13:16:12 +0000
Subject: note 67933 modified in function.imagegif by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156596@lists.php.net to get a copy of this message
to create an animated gif with gifsicle, but without storing temporary images on disk: <?php $cmd = 'gifsicle --loop -O1 --multifile --delay 25 - > '.$outfile; $desc = array(0 => array("pipe", "r"),1 => array("pipe", "w"),2 => array("pipe", "w")); $proc = proc_open($cmd, $desc, $pipes); if (!is_resource($proc)) { die('Unable to start gifsicle'); } for ($frame=0; $frame<$total_frames; $frame++) { $image = RenderFrame($frame); ob_start(); imagegif($image); fwrite($pipes[0], ob_get_contents()); ob_end_clean(); imagedestroy($image); } fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); proc_close($proc); ?> just define $outfile and RenderFrame(), and that's it. --was-- to create an animated gif with gifsicle, but without storing temporary images on disk: <? $cmd = 'gifsicle --loop -O1 --multifile --delay 25 - > '.$outfile; $desc = array(0 => array("pipe", "r"),1 => array("pipe", "w"),2 => array("pipe", "w")); $proc = proc_open($cmd, $desc, $pipes); if (!is_resource($proc)) { die('Unable to start gifsicle'); } for ($frame=0; $frame<$total_frames; $frame++) { $image = RenderFrame($frame); ob_start(); imagegif($image); fwrite($pipes[0], ob_get_contents()); ob_end_clean(); imagedestroy($image); } fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); proc_close($proc); ?> just define $outfile and RenderFrame(), and that's it. http://php.net/manual/en/function.imagegif.php

« previous php.notes (#156596) next »