PHP Classes
elePHPant
Icontem

GIF Animation Resizer: Resize animations in files of the GIF format

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (9)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2012-05-09 (5 years ago) RSS 2.0 feedStarStarStarStar 76%Total: 2,458 This week: 4All time: 1,525 This week: 166Up
Version License PHP version Categories
php-gif-resizer 1.0MIT/X Consortium ...5.0PHP 5, Graphics, Video
Description Author

This class can resize animations in files of the GIF format.

It can take an animated GIF image file and extracts its frames to files into a temporary directory.

The class resizes the extracted images and rebuilds the animation into a new file in the GIF format.

Innovation Award
PHP Programming Innovation award nominee
February 2012
Number 3


Prize: One downloadable copy of PhpED Professional
GIF is an image file format that can be used to present animations by showing a sequence of images stored inside the same GIF image file.

If you need to show a GIF animation in an image size different than the original, you need to extract all the animation frames, resize each of them and rebuild the animation with the desired size. This class does that.

Manuel Lemos
  Performance   Level  
Name: Taha Paksu <contact>
Classes: 3 packages by
Country: Turkey Turkey
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Details
PHP GIF Animation Resizer
(written by Taha PAKSU <tpaksu (at) gmail (dot) com>)

.:: INTRODUCTION ::.

This class resizes GIF Animations by parsing the GIF animation into seperate
GIF Images and combining them after desired resize operation. It's written because
there is not so many sources about this operation and PHP's GD library didn't 
support it, ImageMagick succeeds it with some executable file etc.


.:: DEPENDENCIES ::.

- PHP 5 or higher
- GD Image Library


.:: FEATURES ::.

- Light and easy to use
- Needs a temp directory for frames
- Delay Timings and Disposal Methods stay the same
- Minimum diffusion
- Tested with several GIF animations

.:: EXAMPLES ::.

See the attached examples files for more information.

Just download the whole package and extract it into a web directory.
After that, just call test.php script within you browser and have fun.

.:: DOCUMENTATION ::.

Code is partly explained in the class file. But there are some points to look first:

1. You need to create a folder and make it writeable (CHMOD 777) and set the 
$class->temp_dir variable to point that folder. Because it needs a folder to extract
the frames.

2. The paths should be relative and existing. You should define the new file path with an
existing and writeable folder.

3. This class has only one function and it is $class->resize(). It's used like this : 

	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->resize({file to be resized}, {new file to be created}, {new width}, {new height});

and that's all. 

.:: SUPPORT ::.

If you made efforts to add features, bugfixes, complain about the
uselessness of this class, or you simply want to leave a personal comment, 
you are welcome to write me, and explain what you have done and why.
Screenshots  
  • 1_resized.gif
  Files folder image Files  
File Role Description
Files folder imageframes (1 file)
Files folder imagegifs (1 file)
Files folder imageresized (1 file)
Accessible without login Plain text file gifresizer.php Class Main Class File
Accessible without login Plain text file readme.txt Doc. Readme & Documentation
Accessible without login Plain text file test.php Example Test & Example File

  Files folder image Files  /  frames  
File Role Description
  Accessible without login Plain text file placeholder.txt Data File not neccessary but the folder is.

  Files folder image Files  /  gifs  
File Role Description
  Accessible without login Image file 1.gif Icon Test & Example File

  Files folder image Files  /  resized  
File Role Description
  Accessible without login Image file 1_resized.gif Output Example Output

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,458
This week:4
All time:1,525
This week:166Up
User Ratings User Comments (3)
 All time
Utility:96%StarStarStarStarStar
Consistency:93%StarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:96%StarStarStarStarStar
Tests:-
Videos:-
Overall:76%StarStarStarStar
Rank:88
 
Its really a awesome class.
3 years ago (Dhamodharan R)
80%StarStarStarStarStar
Thanks
3 years ago (Guillermo Chigo)
80%StarStarStarStarStar
This class is the best on web ! good job.
5 years ago (alyn)
77%StarStarStarStar