astrotomic/countdown-gif

此包已被废弃,不再维护。未建议替代包。

倒计时-Gif 生成器

dev-main 2020-09-09 19:30 UTC

This package is not auto-updated.

Last update: 2022-11-26 19:23:09 UTC


README

$request = \Illuminate\Http\Request::createFromGlobals();
$timezone = timezone_open((string) $request->get('tz', 'Europe/Berlin'));
$now = new DateTime('now', $timezone);
$target = new DateTime($request->get('t', 'now'), $timezone);
$runtime = max(0, min(300, $request->get('r', 10)));
$default = $request->get('d');
$format = $request->get('f', '{d}:{h}:{m}:{s}');

$width = intval($request->get('w', 500));
$height = intval($request->get('h', 50));
$bgColor = '#'.$request->get('bg', 'ffffff');

$fontType = $request->get('ft');
$fontSize = intval($request->get('fs', 48));
$fontColor = $request->get('fc', '#ff0000');

$formatter = new \Astrotomic\CountdownGif\Helper\Formatter($format);

$background = new Imagick();
$background->setFormat('png');
$background->newImage($width, $height, $bgColor);

$font = new \Astrotomic\CountdownGif\Helper\Font($fontType, $fontSize, $fontColor, [
    'lato' => resource_path('lato-regular.ttf'),
]);

$redis = new \Redis();
$config = app('config')->get('database.redis.default');
$redis->connect($config['host'], $config['port']);
$redisPool = new \Cache\Adapter\Redis\RedisCachePool($redis);

$countDownGif = new \Astrotomic\CountdownGif\CountdownGif($now, $target, $runtime, $formatter, $background, $font, $default, $redisPool, \Cache\Adapter\Common\CacheItem::class);
$gif = $countDownGif->generate($background->getImageWidth() / 2, $background->getImageHeight() / 2);

header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Content-Type: image/gif');
echo $gif->getImagesBlob();

Treeware

您可以使用此包,但如果它进入您的生产环境,我将非常感激您为世界买一棵树。

众所周知,解决气候危机并防止我们的温度上升超过1.5C的最好工具之一是种植树木。如果您为我的森林做出贡献,您将为当地家庭创造就业机会并恢复野生动物栖息地。

您可以在offset.earth/treeware购买树木。

有关Treeware的更多信息,请访问treeware.earth