PHP Classes

File: example/horse.php

Recommend this page to a friend!
  Classes of Patrick Van Bergen   Move Me GIF   example/horse.php   Download  
File: example/horse.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Move Me GIF
Create animated GIF images in pure PHP
Author: By
Last change: Use first-frame dimensions when not specified in GifBuilder constructor.
Use imagegif to create compressed pixel data if possible, which is much faster.
Date: 7 years ago
Size: 725 bytes
 

Contents

Class file image Download
<?php
/**
 * A simple animation created from with 8 png images.
 *
 * The horse images were taken from this Wikipedia page
 *
 * https://en.wikipedia.org/wiki/Animated_cartoon
 */

use movemegif\domain\FileImageCanvas;
use
movemegif\GifBuilder;

// just for debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);

// include movemegif's namespace
require_once __DIR__ . '/../php/autoloader.php';

// no width and height specified: they will be taken from the first frame
$builder = new GifBuilder();
$builder->setRepeat();

for (
$i = 1; $i <= 8; $i++) {

   
$builder->addFrame()
        ->
setCanvas(new FileImageCanvas(__DIR__ . '/horse/' . $i . '.png'))
        ->
setDuration(8);
}

$builder->output('horse.gif');