Ejemplo n.º 1
0
$res->execute();
$url = null;
$res->bind_result($url);
$imgs = array();
while ($res->fetch()) {
    if ($url) {
        # 如果没有缩略图,则尝试创建。
        if (!file_exists($url . "rs")) {
            $org_img = imagecreatefromjpeg($url);
            if ($org_img) {
                list($width, $height) = getimagesize($url);
                $resize_img = imagecreatetruecolor($width * 0.25, $height * 0.25);
                imagecopyresampled($resize_img, $org_img, 0, 0, 0, 0, $width * 0.25, $height * 0.25, $width, $height);
                imagejpeg($resize_img, $url . "rs");
                imagedestroy($resize_img);
                imagedestroy($org_img);
            }
        }
        # 创建成功或原来就有缩略图
        if (file_exists($url . "rs")) {
            array_push($imgs, $url . "rs");
        }
    }
}
// print_r($imgs);
$anim = new GifCreator\AnimGif();
$durations = array(30, 30);
$anim->create($imgs, $durations);
$gif = $anim->get();
header("Content-type: image/gif");
echo $gif;
Ejemplo n.º 2
0
<?php

// Example for creating a slideshow from images in the "./img/" dir.
require "../src/GifCreator/AnimGif.php";
$anim = new GifCreator\AnimGif();
// Load all images from "./img/", in ascending order,
// apply the given delays, and save the result...
$anim->create("img/", array(300, 500))->save("anim.gif");