phpgif/ezgif

v1.0.0 2022-10-17 23:33 UTC

This package is auto-updated.

Last update: 2024-08-22 19:40:06 UTC


README

EZGif

What is EZGif?

EZGif is the simplest way to generate GIFs. It's powered by phpgif/phpgif.

Installing phpgif

Using Composer

Run the following command in Terminal or Command Prompt:

composer require phpgif/ezgif
use phpgif\EZGif\EZGif

Without Composer

When using shared hosting, many hosting providers don't allow Composer. Use the following system to install EZGif:

  1. Download the repo
  2. Open the src/EZGif folder
  3. Copy EZGif.standalone.php onto your webserver
  4. Paste the following code at the top of your file:
include 'EZGif.standalone.php';

Getting Started

Create a new PHP file. Include this at the top:

<?php
use phpgif\EZGif\EZGif;
$ez = new EZGif();

Usage

generateFromDir

This function will generate a GIF from a directory!

$ez->generateFromDir(string $directory, int $delay, array? $filetypes = ['.png', '.jpg', '.jpeg', '.gif', '.tiff', '.bmp', '.ico'])

Example

$ez->generateFromDir('imgs');

** IMPORTANT: For this to work, you must use the displayGif and setHeaders methods. ***

fileListGif

Generate a GIF from a list of files

$ez->generateFileList(array $files, int? $delay = 100)

Example

$ez->generateFileList(['image.png', 'picture.jpg'], 500);

setHeaders

This function will set the headers to prepare the user's browser to render the GIF.

$ez->setHeaders(bool? $disableCache = true, bool? $setContentType = true)

Example

$ez->setHeaders(false) # Enable caching!

displayGif

This function will show the GIF on the webpage, for the user to render. Please note that this function will call exit when it completes. This function takes no parameters.

$ez->displayGif()

Example

$ez->displayGif();

toFile

This function will export the GIF to a file. This function does not require headers to be set.

$ez->toFile(string $fileName)

Example

$ez->toFile('example.gif');

License & Credits

This software is published under the MIT License.

phpgif

This library uses phpgif/phpgif.

GIFEncoder

GIFEncoder.class.php is adapted from the GIFEncoder PHP class by László Zsidi.

© 2023 mrfakename. All rights reserved.