mergegif class. how do I use it?
Moderator: General Moderators
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
mergegif class. how do I use it?
anyone know how to use the mergegif class?
- turbolemon
- Forum Commoner
- Posts: 70
- Joined: Tue Jul 14, 2009 6:45 am
- Location: Preston, UK
Re: mergegif class. how do I use it?
Do you mean this: http://phpclasses.sgboards.com/browse/package/3163.html?
If so, there is a reasonably well commented file called example.php. Here's it's content:
Lines 6-14 open up and read a directory called frames which is relative to the cwd() of the script (skipping the unix . and .. hard-links), into an array of filenames (and delays on a per-frame basis).
Lines 28-35 instantiate the object, using the parameters defined in the comment.
Line 48 outputs the animation.
If so, there is a reasonably well commented file called example.php. Here's it's content:
Code: Select all
<?php
include "GIFEncoder.class.php";
/*
Build a frames array from sources...
*/
if ( $dh = opendir ( "frames/" ) ) {
while ( false !== ( $dat = readdir ( $dh ) ) ) {
if ( $dat != "." && $dat != ".." ) {
$frames [ ] = "frames/$dat";
$framed [ ] = 5;
}
}
closedir ( $dh );
}
/*
GIFEncoder constructor:
=======================
image_stream = new GIFEncoder (
URL or Binary data 'Sources'
int 'Delay times'
int 'Animation loops'
int 'Disposal'
int 'Transparent red, green, blue colors'
int 'Source type'
);
*/
$gif = new GIFEncoder (
$frames,
$framed,
0,
2,
0, 0, 0,
"url"
);
/*
Possibles outputs:
==================
Output as GIF for browsers :
- Header ( 'Content-type:image/gif' );
Output as GIF for browsers with filename:
- Header ( 'Content-disposition:Attachment;filename=myanimation.gif');
Output as file to store into a specified file:
- FWrite ( FOpen ( "myanimation.gif", "wb" ), $gif->GetAnimation ( ) );
*/
Header ( 'Content-type:image/gif' );
echo $gif->GetAnimation ( );
?>Lines 28-35 instantiate the object, using the parameters defined in the comment.
Line 48 outputs the animation.
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
Re: mergegif class. how do I use it?
looks like id rather use Image Magick. I can see its installed on my server but the following code i got from a site to test if it works doesn't work..
Fatal error: Class 'Imagick' not found in /home/tactical/public_html/demo/imagictest.php on line 21
do I need a class for it or should it allready be installed? IF I need a class, where can I download it.
Code: Select all
<?php
header('Content-type: image/png');
$image = new Imagick('data/games/1-9.png');
// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);
echo $image;
?>Fatal error: Class 'Imagick' not found in /home/tactical/public_html/demo/imagictest.php on line 21
do I need a class for it or should it allready be installed? IF I need a class, where can I download it.
- turbolemon
- Forum Commoner
- Posts: 70
- Joined: Tue Jul 14, 2009 6:45 am
- Location: Preston, UK
Re: mergegif class. how do I use it?
Do you get any error messages? As far as I can tell, you can't install the PECL module without the prerequisite binary installed (the module provides the class definitions you use in your PHP code, which is a wrapper for the binary installed on the system). http://php.oregonstate.edu/manual/en/intro.imagick.php
I don't have any experience using ImageMagick to be honest, all my image manipulation has been written for GD. It's one of those things that I have never got round to experimenting with!
I don't have any experience using ImageMagick to be honest, all my image manipulation has been written for GD. It's one of those things that I have never got round to experimenting with!