PHP code example of niweisi / php-poster

1. Go to this page and download the library: Download niweisi/php-poster 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/ */

    

niweisi / php-poster example snippets




use niweisi\Poster\GifCreator\GifCreator;

// 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.


$frames = array(
    "../images/newyear.jpg",
    "../images/newyear_count.png",
);

// Create an array containing the duration (in millisecond) of each frames (in order too)
$durations = array(150, 150);

// Initialize and create the GIF !
$gc = new GifCreator();
$gc->create(
    $frames,
    $durations,
    0 // 动画停止前的GIF循环次数(设置为0以获得无限循环)
);
$gifBinary = $gc->getGif();
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-type: image/gif');
header('Content-Disposition: filename="butterfly.gif"');
echo $gifBinary;
exit;




use niweisi\Poster\Compress\Compress;

$html = file_get_contents('./test.html');
$html = Compress::html($html); // 压缩html文件
echo $html;
exit;