Skip to content

Commit

Permalink
Add readme info
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Jan 4, 2024
1 parent a426734 commit e75bad5
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
![build](https://github.com/Intervention/gif/actions/workflows/build.yml/badge.svg)
[![Monthly Downloads](https://img.shields.io/packagist/dm/intervention/gif.svg)](https://packagist.org/packages/intervention/gif/stats)

Intervention GIF is a PHP encoder and decoder for the GIF image format that
does not depend on any image processing extension.

Only the special `Splitter::class` class divides the data stream of an animated
GIF into individual `GDImage´ objects for each frame and therefore depend on
the GD library.

## Installation

You can install this package easily with [Composer](https://getcomposer.org/). Just require the package with the following command:
You can easily install this package using [Composer](https://getcomposer.org).
Just request the package with the following command:

```bash
composer require intervention/gif
Expand All @@ -21,7 +29,7 @@ composer require intervention/gif
use Intervention\Gif\Decoder;

// Decode filepath to Intervention\Gif\GifDataStream::class
$gif = Decoder::decode('/images/animation.gif');
$gif = Decoder::decode('images/animation.gif');

// Decoder can also handle binary content directly
$gif = Decoder::decode($contents);
Expand All @@ -34,12 +42,8 @@ Use the Builder class to create a new GIF image.
```php
use Intervention\Gif\Builder;

// create an empty canvas
$width = 32;
$height = 32;

// create new gif with width/height
$gif = Builder::canvas($width, $height);
// create new gif canvas
$gif = Builder::canvas(width: 32, height: 32);

// add animation frames to canvas
$delay = .25; // delay in seconds after next frame is displayed
Expand All @@ -48,10 +52,10 @@ $top = 0; // position offset (top)

// add animation frames with optional delay in seconds
// and optional position offset for each frame
$gif->addFrame('/images/frame01.gif', $delay, $left, $top);
$gif->addFrame('/images/frame02.gif', $delay, $left);
$gif->addFrame('/images/frame03.gif', $delay);
$gif->addFrame('/images/frame04.gif');
$gif->addFrame('images/frame01.gif', $delay, $left, $top);
$gif->addFrame('images/frame02.gif', $delay, $left);
$gif->addFrame('images/frame03.gif', $delay);
$gif->addFrame('images/frame04.gif');

// set loop count; 0 for infinite looping
$gif->setLoops(12);
Expand Down

0 comments on commit e75bad5

Please sign in to comment.