Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>just creat 3 folder name 1.frame_output 2.images 3.resized_frame_output and download 2 encoder and decoder class from this below link 1.Download class "GIFDecoder.class.php" from <a href="http://phpclasses.elib.com/browse/package/3234.html" rel="nofollow noreferrer">http://phpclasses.elib.com/browse/package/3234.html</a> 2.Download class "GIFEncoder.class.php" from <a href="http://phpclasses.betablue.net/browse/package/3163.html" rel="nofollow noreferrer">http://phpclasses.betablue.net/browse/package/3163.html</a> </p> <p>and then run the script name as "resize_animator.php" , creat a upload html file &amp; Let Enjoy the script.</p> <p>..save this script as .....index.php.......</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"&gt; &lt;tr&gt; &lt;form action="resize_animator.php" method="post" enctype="multipart/form-data" &gt; &lt;td&gt; &lt;table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"&gt; &lt;tr&gt; &lt;td align="center"&gt;&lt;font face="Tahoma"&gt;SELECT ANIMATED FILE&lt;/font&gt; &lt;input type="file" name="uploadfile" size="20" accept="image/gif"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center"&gt;&lt;input type="submit" name="Submit" value="PROCESS ANIMATION" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/form&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>........................save and this script as resize_animator.php............</p> <pre><code> &lt;?php require "GIFDecoder.class.php"; include "GIFEncoder.class.php"; $file_name= $_FILES['uploadfile']['name']; $file_ext = substr($file_name, -4); $file_size=($_FILES["uploadfile"]["size"] /1024 ); if($file_ext=='.gif') { if($file_size &gt; 0 &amp;&amp; $file_size &lt; 2000 ) { session_start ( ); $uploaded_file = $_FILES['uploadfile']['tmp_name']; $fp=file_get_contents($uploaded_file); if ( $fp ) { $_SESSION['delays'] = Array ( ); $gif = new GIFDecoder ( $fp ); $arr = $gif-&gt;GIFGetFrames ( ); $_SESSION [ 'delays' ] = $gif -&gt; GIFGetDelays ( ); for ( $i = 0; $i &lt; count ( $arr ); $i++ ) { fwrite ( fopen ( ( $i &lt; 10 ? "frame_output/$i$i_frame.gif" : "frame_output/$i_frame.gif" ), "wb" ), $arr [ $i ] ); } } function resize_frames($newwidth,$newheight) { $dir=opendir("frame_output/"); $i=0; while($imgfile=readdir($dir)) { if ($imgfile != "." &amp;&amp; $imgfile!="..") { $imgarray[$i]=$imgfile; $uploadedfile = "frame_output/".$imgarray[$i]; $src = imagecreatefromgif($uploadedfile); list($width,$height)=getimagesize($uploadedfile); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = "resized_frame_output/".$imgarray[$i]; imagegif($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); $i++; } } closedir($dir); if ( $dh = opendir ( "resized_frame_output/" ) ) { while ( false !== ( $dat = readdir ( $dh ) ) ) { if ( $dat != "." &amp;&amp; $dat != ".." ) { $frames [ ] = "resized_frame_output/$dat"; } } closedir ( $dh ); } $gif = new GIFEncoder ( $frames,$_SESSION [ 'delays' ],0, 2, 0, 0, 0,"url" ); $data = $gif-&gt;GetAnimation ( ); $x='x'; $y='_'; $uploaded_file_name= $_FILES['uploadfile']['name']; $actual_file_name = substr($uploaded_file_name, 0, -4); $file_extention = substr($uploaded_file_name, -4); $new_name=$actual_file_name.$y.$newwidth.$x.$newheight.$file_extention ; //$output_image_name=$newwidth.$x.$newheight; fwrite ( fopen ( "images/$new_name", "wb" ), $data ); //remove resized frames from folder //sleep for 1 second // usleep(2000000); $dir = 'resized_frame_output/'; foreach(glob($dir.'*.*') as $v) { unlink($v); } } // end of function resize_frames $gif = new GIFEncoder ( $frames,$_SESSION [ 'delays' ],0, 2, 0, 0, 0,"url" ); $data = $gif-&gt;GetAnimation ( ); $x='x'; $y='_'; $z='_p'; $uploaded_file_name= $_FILES['uploadfile']['name']; $actual_file_name = substr($uploaded_file_name, 0, -4); $file_extention = substr($uploaded_file_name, -4); $new_name=$actual_file_name.$y.$newwidth.$x.$newheight.$z.$file_extention ; //$output_image_name=$newwidth.$x.$newheight; fwrite ( fopen ( "images/$new_name", "wb" ), $data ); //remove resized frames from folder //sleep for 1 second //usleep(2000000); $dir = 'resized_frame_output/'; foreach(glob($dir.'*.*') as $v) { unlink($v); } } // end of function resize_frames resize_frames(110,110); resize_frames(120,160); resize_frames(120,80); resize_frames(128,96); resize_frames(128,128); resize_frames(208,208); resize_frames(208,320); session_destroy(); //usleep(200000); //remove resized frames from folder $dir = 'frame_output/'; foreach(glob($dir.'*.*') as $v) { unlink($v); } echo "&lt;center&gt;&lt;h1&gt;Your Animation processing is compleated.&lt;/h1&gt;&lt;/center&gt;"; echo "&lt;center&gt;&lt;h2&gt;&lt;a href=\"index.php\"&gt;BACK TO UPLOAD PAGE&lt;/h2&gt;&lt;/center&gt;"; } //end of file size checker else { echo "&lt;center&gt;&lt;h2&gt;You Upload a unfit size image .Upload a file within 2000 KB&lt;/h2&gt;&lt;/center&gt;"; echo "&lt;center&gt;&lt;h2&gt;&lt;a href=\"index.php\"&gt;BACK TO UPLOAD PAGE&lt;/h2&gt;&lt;/center&gt;"; } } //end of file extention checker else { echo "&lt;center&gt;&lt;h2&gt;Uplaod a gif file!&lt;/h2&gt;&lt;/center&gt;"; echo "&lt;center&gt;&lt;h2&gt;&lt;a href=\"index.php\"&gt;BACK TO UPLOAD PAGE&lt;/h2&gt;&lt;/center&gt;"; } ?&gt; </code></pre> <p>.......................LETS ENJOY............</p> <p>uncomment the usleep function to see the work happen into those folders.its not necessary but i use it to see the functionality.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload