php-gif
php-gif copied to clipboard
how do
for a folder, how do I run it?
http://countdown.ayhanmalkoc.com/gif.php
Please be more specific. What do you want with that folder? You should be able to create a file which generates a GIF without much trouble, by following the README. If the README is unclear at some point, please let me know.
the Readme is unclear for me :S
the Readme is unclear for me :S
Can you be more specific? What is confusing to you? Where do you get stuck? Where you able to install composer etc.?
I wont ceate a gif with your class without a countdown on it. Only 3 images from a folder to a gif. Lots of classes can't show a Transparent Background, but I think youre class can do it. Did you have some example for this? http://attractive.coffee/dancegenerator/?user=hoteluser this script shows what i want to do, but with my own images
Update
With ezgif, you can easily scan from a directory.
composer require phpgif/ezgif
use phpgif\EZGif\EZGif;
$ez = new EZGif();
$ez->setHeaders(false);
$ez->generateFromDir('imgs');
$ez->displayGif();
Original Answer
You can loop through scandir. Here's an example:
Please note that this example uses the transparent attribute which won't work unless your using phpgif, an improved and maintained fork of PHP-GIF.
<?php
include 'GIFEncoder.php';
include 'GIFGenerator.php';
header ('Content-type: image/gif');
$gif = new GIFGenerator();
$imageExt = '.jpg';
$delay = 100;
$dir = 'images/';
$gifframes = [];
$frames = scandir($dir);
foreach ($frames as $frame) {
if (strrpos($frame, $imageExt) === strlen($frame) - strlen($imageExt)) {
array_push($gifframes, [
'image' => $dir . $frame,
'delay' => $delay
]);
}
}
$imageFrames = [
'repeat' => false,
'transparent' => true,
'frames' => $gifframes,
'repeat' => true
];
echo $gif->generate($imageFrames);
I tested this solution on PHP 8. Please note that on large photos, the memory may be exhausted. You can fix this by resizing the photos.
Again, some functions used in this example requires phpgif.