PHPackages                             intervention/gif - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. intervention/gif

ActiveLibrary[Image &amp; Media](/categories/media)

intervention/gif
================

PHP GIF Encoder/Decoder

5.0.0(1mo ago)5720.3M—4.2%9[2 issues](https://github.com/Intervention/gif/issues)9MITPHPPHP ^8.3CI passing

Since Sep 8Pushed 1w agoCompare

[ Source](https://github.com/Intervention/gif)[ Packagist](https://packagist.org/packages/intervention/gif)[ Docs](https://github.com/intervention/gif)[ Fund](https://paypal.me/interventionio)[ GitHub Sponsors](https://github.com/Intervention)[ RSS](/packages/intervention-gif/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (6)Dependencies (8)Versions (33)Used By (9)

Intervention GIF
================

[](#intervention-gif)

Native PHP GIF Encoder/Decoder
------------------------------

[](#native-php-gif-encoderdecoder)

[![Latest Version](https://camo.githubusercontent.com/b8ac5ccd5485cc396e42a4aee0b199160b2f88f137015848a0f14a171007a0c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e74657276656e74696f6e2f6769662e737667)](https://packagist.org/packages/intervention/gif)[![build](https://github.com/Intervention/gif/actions/workflows/build.yml/badge.svg)](https://github.com/Intervention/gif/actions/workflows/build.yml/badge.svg)[![Monthly Downloads](https://camo.githubusercontent.com/8cc9bbf27f8d1d09fe0b6fd4e4505056ce30f59618527fff3faecbdd04be89c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f696e74657276656e74696f6e2f6769662e737667)](https://packagist.org/packages/intervention/gif/stats)[![Support me on Ko-fi](https://raw.githubusercontent.com/Intervention/gif/main/.github/images/support.svg)](https://ko-fi.com/interventionphp)

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 is therefore dependent on the GD library.

The library is the main component of [Intervention Image](https://github.com/Intervention/image) for processing animated GIF files with the GD library, but also works independently.

Installation
------------

[](#installation)

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

```
composer require intervention/gif
```

Code Examples
-------------

[](#code-examples)

### Decoding

[](#decoding)

```
use Intervention\Gif\Decoder;

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

// Decoder can also handle binary content directly
$gif = Decoder::decode($contents);
```

### Encoding

[](#encoding)

Use the Builder class to create a new GIF image.

```
use Intervention\Gif\Builder;

// 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
$left = 0; // position offset (left)
$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');

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

// encode
$data = $gif->encode();
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3

Development &amp; Testing
-------------------------

[](#development--testing)

With this package comes a Docker docker test runners. To build this container you have to have Docker installed on your system. You can run all tests with this command.

```
docker-compose run --rm --build tests
```

Run the static analyzer on the code base.

```
docker-compose run --rm --build analysis
```

Authors
-------

[](#authors)

This library is developed and maintained by [Oliver Vogel](https://intervention.io)

Thanks to the community of [contributors](https://github.com/Intervention/gif/graphs/contributors) who have helped to improve this project.

License
-------

[](#license)

Intervention GIF is licensed under the [MIT License](LICENSE).

###  Health Score

72

—

ExcellentBetter than 100% of packages

Maintenance93

Actively maintained with recent releases

Popularity62

Solid adoption and visibility

Community20

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 99.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~132 days

Recently: every ~19 days

Total

30

Last Release

59d ago

Major Versions

1.0.1-beta2 → 3.0.0-alpha.12021-10-29

3.0.0 → 4.0.02024-01-06

4.2.2 → 5.0.0-beta.12025-12-30

4.2.3 → 5.0.0-beta.52026-01-04

4.2.4 → 5.0.02026-03-21

PHP version history (6 changes)0.5.0PHP &gt;=5.3.0

1.0.0-alphaPHP ^7.2

1.0.1-betaPHP ^7.3|^8.0

3.0.0-alpha.2PHP ^8.0

4.0.0PHP ^8.1

5.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d172b42b2c5b53e71e56589fed3fb3467234a1c266d31b697b1d7b451f4cfe8?d=identicon)[olivervogel](/maintainers/olivervogel)

---

Top Contributors

[![olivervogel](https://avatars.githubusercontent.com/u/884642?v=4)](https://github.com/olivervogel "olivervogel (216 commits)")[![deluxetom](https://avatars.githubusercontent.com/u/6439307?v=4)](https://github.com/deluxetom "deluxetom (1 commits)")

---

Tags

imagegdgifanimation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/intervention-gif/health.svg)

```
[![Health](https://phpackages.com/badges/intervention-gif/health.svg)](https://phpackages.com/packages/intervention-gif)
```

###  Alternatives

[intervention/image

PHP Image Processing

14.3k194.3M2.2k](/packages/intervention-image)[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k51.2M116](/packages/league-glide)[gregwar/image

Image handling

1.0k4.1M51](/packages/gregwar-image)[sybio/image-workshop

Powerful PHP class using GD library to work easily with images including layer notion (like Photoshop or GIMP)

860918.1k11](/packages/sybio-image-workshop)[intervention/image-laravel

Laravel Integration of Intervention Image

1536.5M102](/packages/intervention-image-laravel)[james-heinrich/phpthumb

The PHP thumbnail generator

318516.1k6](/packages/james-heinrich-phpthumb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
