Download the PHP package erikvdven/php-gif without Composer
On this page you can find all versions of the php package erikvdven/php-gif. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-gif
php-gif
IMPORTANT NOTE: This repository is not actively maintained anymore. I moved from PHP to Python years ago, so that's basically why. If you would like to contribute on this repository, feel free to open up a PR and perhaps I can add you as a contributor as well. There are also people who forked this repository and decided to built further on that. For a fork which is compatible with PHP 8, see phpgif/phpgif
Below GIF image is an example image which can contain real-time data. A PHP script calculates the pending time till new year and generates the GIF image. An ideal solution for sending e-mails with real-time data to customers. E-mail clients give you the opportunity to load images by URL and so everytime the client re-opens the e-mail message, the GIF will be re-generated with real-time data.
For below image this doesn't work, unfortunately, because GitHub downloads the image once and stores it locally. Most e-mail clients, however, do load the images directly from source. Successfully tested with Gmail and Outlook 2011 (Mac OSX).
Note
I received some questions about Gmail so lets describe this mail client a bit more in detail. This script is successfully tested with Gmail, at the moment of writing, which is 2015-12-23. Gmail loads the images via their own proxy, so not directly from source. There are different opinions about the proxy, but it seems that Google's proxy protects your private data and only informs the sender that the email has been opened. There are speculations that Gmail caches the images, but still respect the cache headers, so you can instruct Gmail how often to refresh the data. I personally had no trouble with the cache whatsoever! I've tested this countdown image numerous times in Gmail and of course you can test it yourself as well. Just to be sure I've added some cache disabling headers in the examples.
Composer Installation
- Get Composer
- Require php-gif with
composer require erikvdven/php-gif
- Add the following to your application's main PHP file:
require 'vendor/autoload.php';
Getting Started
Create a PHP file and add these headers at the beginning of the file:
On the next lines you can create a GIF image by first initializing the GIFGenerator object and creating an array with all the image frames:
Finally you generate the image and echo
the results on the screen:
Example
A more complete example. You could copy/paste below code to a file and execute it in the browser to view a more complete result. As you can see it's not required to use text in your GIF image and you can add as much text per frame, and as much frames per GIF image as you like.
License & Credits
This software is published under the MIT License.
GIFEncoder
GIFEncoder.class.php contains minor adaptations from the GIFEncoder PHP class by László Zsidi.