PHP code example of intervention / gif

1. Go to this page and download the library: Download intervention/gif library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

intervention / gif example snippets


use Intervention\Gif\Decoder;

// Decode filepath to Intervention\Gif\GifDataStream::class
$gif = Decoder::decode('images/animation.gif');

// Decoder can also handle binary content directly
$gif = Decoder::decode($contents);

use Intervention\Gif\Builder;

// create new gif canvas
$gif = Builder::canvas(width: 32, height: 32);

// add animation frames to canvas
$delay = .25; // delay in seconds after next frame is displayed
$left = 0; // position offset (left)
$top = 0; // position offset (top)

// add animation frames with optional delay in seconds
// and optional position offset for each frame
$gif->addFrame('images/frame01.gif', $delay, $left, $top);
$gif->addFrame('images/frame02.gif', $delay, $left);
$gif->addFrame('images/frame03.gif', $delay);
$gif->addFrame('images/frame04.gif');

// set loop count; 0 for infinite looping
$gif->setLoops(12);

// encode
$data = $gif->encode();