web analytics
you're reading...

Featured

PHP Animated Gif Resizer

There are many sites that use avatars and sometimes they use animated GIF files. But when it comes to resizing them, it really becomes a pain when your server doesn’t support ImageMagick. So I decided to write an animated GIF resizer based on GD Library (Because GD doesn’t support it directly either.)

It works like this:

  1. Extract frames from GIF animations into a temporary folder.
  2. Resizes all the frames
  3. Combines them into one file

Using this class is really simple. Here is the code

<?php
include_once "gifresizer.php";
$gr = new gifresizer;
$gr->temp_dir = "frames"; //note that it doesn't end with a "/"
$gr->resize("gif/1.gif","resized/1.gif",200,300);

// $gr->temp_dir = {a folder with a write permission (777)}; // The temporary folder which frames will be extracted to.
// $gr->resize({file to be resized}, {new file to be created}, {new width}, {new height});
?>

Here’s an example:

 

Original GIF file :

    

Resized Image:

    

Here you can download the class, documentation and examples.

PHPClasses.org class main page

 

Note: I’m expecting some feedback. Here or at phpclasses.org. Doesn’t matter. If you are using it, tell me how it works.



Categories

Son Yazılar // Recent Posts

jQuery Scrolite Plugin
April 14, 2012
By Taha Paksu
Yine yarışmadayım!
March 1, 2012
By Taha Paksu
SASS User Tool for Editplus
February 22, 2012
By Taha Paksu
Installing SASS on Windows
February 22, 2012
By Taha Paksu
SASS – Syntatically Awesome Stylesheets
February 22, 2012
By Taha Paksu
Bir isim koyma hikayesi: nelm.io
February 21, 2012
By Taha Paksu
PHP Animated Gif Resizer
February 13, 2012
By Taha Paksu
about costabrava hack and some fix.
February 11, 2012
By Taha Paksu