php-gif icon indicating copy to clipboard operation
php-gif copied to clipboard

how do

Open ayhanmalkoc opened this issue 7 years ago • 6 comments

for a folder, how do I run it?

ayhanmalkoc avatar Nov 15 '17 10:11 ayhanmalkoc

http://countdown.ayhanmalkoc.com/gif.php

ayhanmalkoc avatar Nov 15 '17 13:11 ayhanmalkoc

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.

ErikvdVen avatar Apr 23 '18 10:04 ErikvdVen

the Readme is unclear for me :S

BartTotal avatar May 05 '19 21:05 BartTotal

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

ErikvdVen avatar May 06 '19 07:05 ErikvdVen

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

BartTotal avatar May 09 '19 18:05 BartTotal

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.

fakerybakery avatar Oct 15 '22 23:10 fakerybakery