Files
test/gif2.php
2025-11-27 22:25:36 +00:00

70 lines
1.8 KiB
PHP

<?php
include "AnimGif.php";
error_reporting(E_ALL);
ini_set('display_errors', 'on');
// Create an array containing file paths, resource var (initialized with imagecreatefromXXX),
// image URLs or even binary code from image files.
// All sorted in order to appear.
//$array=json_decode($_POST['camarray']);
// Use an array containing file paths, resource vars (initialized with imagecreatefromXXX),
// image URLs or binary image data.
//$elements = $_POST['data'];
$elements = $_POST['data'];
$numimages = $_POST['images'];
$delay = $_POST['delay'];
$lastdelay = $_POST['lastdelay'];
$numimages = $numimages - 2;
//$elements = json_decode($elements);
// Or: load images from a dir (sorted, skipping .files):
//$elements = "./camdata/177/";
//$elements = array(
// "http://wx.stoat.org/camdata/177/8d55c896b3f5acbafcccc9293e2a82d5.png",
// "http://wx.stoat.org/camdata/177/e2cebde9c999352225b6653696c02a98.png" // image file path
//);
// Optionally: set different durations (in 1/100s units) for each frame
//$durations = array(20);
$durations = array_fill(0, $numimages, $delay);
array_push($durations, $lastdelay);
// Or: you can leave off repeated values from the end:
//$durations = array(20, 30, 10); // use 10 for the rest
// Or: use 'null' anywhere to re-apply the previous delay:
//$durations = array(250, null, null, 500);
$anim = new GifCreator\AnimGif();
$anim->create($elements, $durations);
// Or: using the default 100ms even delay:
//$anim->create($elements);
// Or: loop 5 times, then stop:
//$anim->create($frames, $durations, 5); // default: infinite looping
$gif = $anim->get();
//header("Content-Type: text/plain");
//$gif = file_get_contents('test.png');
//echo var_dump($_POST['elements']);
//echo 'hi';
echo base64_encode($gif);
//echo var_dump($elements);
//echo 'test';
exit;
?>