Advertisement
Guest User

reverse-gif-frames

a guest
Feb 20th, 2010
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.55 KB | None | 0 0
  1. <?php
  2.  
  3. //You can try this out at http://home.xtil.net:8000/reversegif/index.php
  4. //It might not be online at all times, though.
  5. //This code is licensed as public domain. Do whatever you want with it.
  6. //Requires Linux, an HTTP server, PHP, and ImageMagick.
  7.  
  8. if ($_FILES["image"]) {
  9.  if ($_FILES["image"]["error"] <= 0) {
  10.   if ($_FILES["image"]["type"] == "image/gif") {
  11.    $id = rand(100, 999);
  12.    $store = dirname(__FILE__) . "/tmp/";
  13.    move_uploaded_file($_FILES["image"]["tmp_name"], $store . $id . "original.gif");
  14.    exec("convert -coalesce " . $store . $id . "original.gif " . $store . $id . ".png");
  15.    exec("ls -1vr --color=none " . $store . $id . "\-*", $filelist);
  16.    exec("convert -delay " . intval($_POST["framerate"]) . " -loop 0 " . implode(" ", $filelist) . " " . $store . "../reversed/" . $id . ".gif");
  17.    exec("rm " . $store . $id . "*");
  18.    header("Location: reversed/" . $id . ".gif");
  19.   }
  20.   else {
  21.    echo "File should be a gif.";
  22.   }
  23.  }
  24.  else {
  25.   echo "Error " . $_FILES["image"]["error"];
  26.  }
  27. }
  28. else {
  29. ?><html><head><title>Reverse GIF</title></head><body>
  30. <p>Here's a quick and easy way to reverse the frame order of an animated GIF. Please download the output image and host it elsewhere, rather than hotlinking!</p>
  31. <form action="index.php" method="post" enctype="multipart/form-data"><fieldset>
  32. Image (max size 1MB): <input type="file" name="image" /><br />
  33. Framerate (centiseconds): <input type="text" name="framerate" value="10" /><br /><input type="submit" value="Reverse it" />
  34. </fieldset></form></body></html><?php
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement