AnimatedGif
in package
AnimatedGif represents an animated gif object.
This class in implemented in rather un-orthodox way. Reason is that ffmpeg doesn't provide satisfactory quality and compression of animated gifs.
Code fragments used from: GIFEncoder Version 2.0 by László Zsidi
Table of Contents
- $counter : mixed
- Counter of first animation.
- $frameRate : int
- Frame rate of the animated gif in frames per second.
- $frames : array<string|int, mixed>
- Binary data of gif files to create animation.
- $gifData : string
- Gif binary data of animation.
- $height : int
- Height of the animated gif.
- $loopCount : int
- Number of times to loop the animation. Put a zero here to loop forever or omit this parameter to disable looping.
- $outFilePath : string
- Location in the filesystem where the animated gif will be written.
- $width : int
- Width of the animated gif.
- __construct() : mixed
- Create a new AnimatedGif object.
- __serialize() : array<string|int, mixed>
- String representation of an AnimatedGif.
- __unserialize() : void
- Constructs the AnimatedGif.
- addFrame() : mixed
- Add a frame to the end of the animated gif.
- getAnimation() : string|bool
- Getting animation binary data.
- save() : bool
- Saving animated gif to remote file.
- addFrameData() : void
- Adding frame binary data to the animation.
- addGifFooter() : void
- Adding footer to the animation.
- addGifHeader() : void
- Adding header to the animation.
- getGifWord() : string
- Gif integer wrapper.
- gifBlockCompare() : bool
- Gif compare block.
Properties
$counter
Counter of first animation.
protected
mixed
$counter
$frameRate
Frame rate of the animated gif in frames per second.
protected
int
$frameRate
$frames
Binary data of gif files to create animation.
protected
array<string|int, mixed>
$frames
$gifData
Gif binary data of animation.
protected
string
$gifData
$height
Height of the animated gif.
protected
int
$height
$loopCount
Number of times to loop the animation. Put a zero here to loop forever or omit this parameter to disable looping.
protected
int
$loopCount
$outFilePath
Location in the filesystem where the animated gif will be written.
protected
string
$outFilePath
$width
Width of the animated gif.
protected
int
$width
Methods
__construct()
Create a new AnimatedGif object.
public
__construct(string $outFilePath, int $width, int $height, int $frameRate, int $loopCount) : mixed
Parameters
- $outFilePath : string
-
Location in the filesystem where the animated gif will be written.
- $width : int
-
Width of the animated gif.
- $height : int
-
Height of the animated gif.
- $frameRate : int
-
Frame rate of the animated gif in frames per second.
- $loopCount : int
-
Number of times to loop the animation. Put a zero here to loop forever or omit this parameter to disable looping.
Return values
mixed —__serialize()
String representation of an AnimatedGif.
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —The string representation of the object or null.
__unserialize()
Constructs the AnimatedGif.
public
__unserialize(array<string|int, mixed> $serialized) : void
Parameters
- $serialized : array<string|int, mixed>
-
The string representation of the object.
Return values
void —addFrame()
Add a frame to the end of the animated gif.
public
addFrame(Frame $frame) : mixed
Parameters
- $frame : Frame
-
Frame to add.
Return values
mixed —getAnimation()
Getting animation binary data.
public
getAnimation() : string|bool
Return values
string|bool —save()
Saving animated gif to remote file.
public
save() : bool
Return values
bool —addFrameData()
Adding frame binary data to the animation.
protected
addFrameData(int $i, int $d) : void
Parameters
- $i : int
-
Index of frame from AnimatedGif::frame array.
- $d : int
-
Delay (5 seconds = 500 delay units).
Return values
void —addGifFooter()
Adding footer to the animation.
protected
addGifFooter() : void
Return values
void —addGifHeader()
Adding header to the animation.
protected
addGifHeader() : void
Return values
void —getGifWord()
Gif integer wrapper.
protected
getGifWord(int $int) : string
Parameters
- $int : int
Return values
string —gifBlockCompare()
Gif compare block.
protected
gifBlockCompare(string $globalBlock, string $localBlock, int $len) : bool
Parameters
- $globalBlock : string
- $localBlock : string
- $len : int