PHPackages                             serafim/ffi-sdl-image - 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. serafim/ffi-sdl-image

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

serafim/ffi-sdl-image
=====================

SDL Image FFI bindings for the PHP language

2.0.2(1y ago)13481MITCPHP ^8.1CI passing

Since Apr 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/SerafimArts/ffi-sdl-image)[ Packagist](https://packagist.org/packages/serafim/ffi-sdl-image)[ Docs](https://github.com/SerafimArts/ffi-sdl-image)[ RSS](/packages/serafim-ffi-sdl-image/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (14)Versions (9)Used By (0)

FFI SDL Image Bindings
======================

[](#ffi-sdl-image-bindings)

 [![PHP 8.1+](https://camo.githubusercontent.com/fa8e7e624e6f29d22e2de84bf64f76b374dc9d0eff4440873a01830753b56390/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d696d6167652f726571756972652f7068703f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/ffi-sdl-image) [![SDL_image](https://camo.githubusercontent.com/13f29ee1d66aad2b20947607c15bf62915a9aedde560f02397b00da72bf59bb9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53444c5f696d6167652d322e362e332d3133324234382e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d63253262253262)](https://github.com/libsdl-org/SDL_image) [![Latest Stable Version](https://camo.githubusercontent.com/9b83dffd02b5e42fda26b6c1065a716f5d7c7c31ffe73aead1ad93eae13bae55/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d696d6167652f76657273696f6e3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/ffi-sdl-image) [![Latest Unstable Version](https://camo.githubusercontent.com/52b85f48b0b52678d117958d921a058b2636ad4986bc99ae8d88bc164bf35eb6/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d696d6167652f762f756e737461626c653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/ffi-sdl-image) [![Total Downloads](https://camo.githubusercontent.com/0a72f241c485690079a8cc0570aa51bde14f7c1b6dca1da549ab7dcbcd51ca0e/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d696d6167652f646f776e6c6f6164733f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/ffi-sdl-image) [![License MIT](https://camo.githubusercontent.com/6b6573105d599ddb2cb1c9eca2d20878d6f3488fc848f3913461f48179f1626d/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d696d6167652f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://raw.githubusercontent.com/serafim/ffi-sdl-image/master/LICENSE.md)

A SDL\_image extension FFI bindings for the PHP language compatible with [SDL FFI bindings for the PHP language](https://github.com/SerafimArts/ffi-sdl).

- [System Requirements](#requirements)
- [Installation](#installation)
- [Documentation](#documentation)
- [Initialization](#initialization)
- [Example](#example)

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

[](#requirements)

- PHP ^8.1
- ext-ffi
- Windows, Linux, BSD or MacOS
    - Android, iOS or something else are not supported yet
- SDL and SDL Image &gt;= 2.0

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

[](#installation)

Library is available as composer repository and can be installed using the following command in a root of your project.

```
$ composer require serafim/ffi-sdl-image
```

Additional dependencies:

- Debian-based Linux: `sudo apt install libsdl2-image-2.0-0 -y`
- MacOS: `brew install sdl2_image`
- Window: Can be [downloaded from here](https://github.com/libsdl-org/SDL_image/releases)

Documentation
-------------

[](#documentation)

The library API completely supports and repeats the analogue in the C language.

- [SDL2 Image official documentation](https://www.libsdl.org/projects/SDL_image/docs/index.html)

Initialization
--------------

[](#initialization)

In the case that you need a specific SDL instance, it should be passed explicitly:

```
$sdl = new Serafim\SDL\SDL(version: '2.28.3');
$image = new Serafim\SDL\Image\Image(sdl: $sdl);

// If no argument is passed, the latest initialized
// version will be used.
$image = new Serafim\SDL\Image\Image(sdl: null);
```

> ! It is recommended to always specify the SDL dependency explicitly.

To specify a library pathname explicitly, you can add the `library` argument to the `Serafim\SDL\Image\Image` constructor.

> By default, the library will try to resolve the binary's pathname automatically.

```
// Load library from pathname (it may be relative or part of system-dependent path)
$image = new Serafim\SDL\Image\Image(library: __DIR__ . '/path/to/library.so');

// Try to automatically resolve library's pathname
$image = new Serafim\SDL\Image\Image(library: null);
```

You can also specify the library version explicitly. Depending on this version, the corresponding functions of the SDL Image will be available.

> By default, the library will try to resolve SDL Image version automatically.

```
// Use v2.0.5 from string
$image = new Serafim\SDL\Image\Image(version: '2.0.5');

// Use v2.6.3 from predefined versions constant
$image = new Serafim\SDL\Image\Image(version: \Serafim\SDL\Image\Version::V2_6_3);

// Use latest supported version
$image = new Serafim\SDL\Image\Image(version: \Serafim\SDL\Image\Version::LATEST);
```

To speed up the header compiler, you can use any PSR-16 compatible cache driver.

```
$image = new Serafim\SDL\Image\Image(cache: new Psr16Cache(...));
```

In addition, you can control other preprocessor directives explicitly:

```
$pre = new \FFI\Preprocessor\Preprocessor();
$pre->define('true', 'false'); // happy debugging!

$image = new Serafim\SDL\Image\Image(pre: $pre);
```

Example
-------

[](#example)

```
use Serafim\SDL\SDL;
use Serafim\SDL\Image\Image;

$sdl = new SDL();
$image = new Image(sdl: $sdl);

$sdl->SDL_Init(SDL::SDL_INIT_EVERYTHING);
$image->IMG_Init(Image::IMG_INIT_PNG);

$surface = $image->IMG_Load(__DIR__ . '/path/to/image.png');
$image->IMG_SaveJPG($surface, __DIR__ . '/path/to/image.jpg', quality: 80);

$image->IMG_Quit();
$sdl->SDL_Quit();
```

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~242 days

Recently: every ~120 days

Total

8

Last Release

520d ago

Major Versions

1.0.1 → 2.0.0-beta12023-08-11

PHP version history (2 changes)1.0.0PHP &gt;=7.4

2.0.0-beta1PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150420?v=4)[Ruslan Sharipov](/maintainers/Serafim)[@serafim](https://github.com/serafim)

---

Top Contributors

[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (18 commits)")

---

Tags

ffiphpphp-ffisdl2sdl2-imageimagelibrarygraphicsffibindingsopenglsdl

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/serafim-ffi-sdl-image/health.svg)

```
[![Health](https://phpackages.com/badges/serafim-ffi-sdl-image/health.svg)](https://phpackages.com/packages/serafim-ffi-sdl-image)
```

###  Alternatives

[serafim/ffi-sdl

SDL FFI bindings for the PHP language

324.6k3](/packages/serafim-ffi-sdl)[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)[andrewgjohnson/imagettftextblur

imagettftextblur is a drop in replacement for imagettftext with added parameters to add blur, glow and shadow effects to your PHP GD images

27198.4k1](/packages/andrewgjohnson-imagettftextblur)

PHPackages © 2026

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