{"id":15957078,"url":"https://github.com/serafimarts/ffi-sdl-image","last_synced_at":"2026-01-31T03:31:34.711Z","repository":{"id":57048281,"uuid":"249100218","full_name":"SerafimArts/ffi-sdl-image","owner":"SerafimArts","description":"SDL2 Image FFI bindings for the PHP language","archived":false,"fork":false,"pushed_at":"2024-12-04T19:40:44.000Z","size":1509,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-04T20:31:41.431Z","etag":null,"topics":["ffi","php","php-ffi","sdl2","sdl2-image"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SerafimArts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-22T02:41:44.000Z","updated_at":"2024-12-04T19:39:36.000Z","dependencies_parsed_at":"2024-10-30T00:03:05.636Z","dependency_job_id":null,"html_url":"https://github.com/SerafimArts/ffi-sdl-image","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"0a2ad08891a44e199a82a516091ec0bd3dabb1a7"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2Fffi-sdl-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2Fffi-sdl-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2Fffi-sdl-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2Fffi-sdl-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SerafimArts","download_url":"https://codeload.github.com/SerafimArts/ffi-sdl-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230120777,"owners_count":18176462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffi","php","php-ffi","sdl2","sdl2-image"],"created_at":"2024-10-07T13:40:29.537Z","updated_at":"2026-01-31T03:31:34.686Z","avatar_url":"https://github.com/SerafimArts.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FFI SDL Image Bindings\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/ffi-sdl-image\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/ffi-sdl-image/require/php?style=for-the-badge\" alt=\"PHP 8.1+\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/libsdl-org/SDL_image\"\u003e\u003cimg src=\"https://img.shields.io/badge/SDL_image-2.6.3-132B48.svg?style=for-the-badge\u0026logo=c%2b%2b\" alt=\"SDL_image\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/ffi-sdl-image\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/ffi-sdl-image/version?style=for-the-badge\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/ffi-sdl-image\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/ffi-sdl-image/v/unstable?style=for-the-badge\" alt=\"Latest Unstable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/ffi-sdl-image\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/ffi-sdl-image/downloads?style=for-the-badge\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://raw.githubusercontent.com/serafim/ffi-sdl-image/master/LICENSE.md\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/ffi-sdl-image/license?style=for-the-badge\" alt=\"License MIT\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nA SDL_image extension FFI bindings for the PHP language compatible with [SDL FFI bindings for the PHP language](https://github.com/SerafimArts/ffi-sdl).\n\n- [System Requirements](#requirements)\n- [Installation](#installation)\n- [Documentation](#documentation)\n- [Initialization](#initialization)\n- [Example](#example)\n\n## Requirements\n\n- PHP ^8.1\n- ext-ffi\n- Windows, Linux, BSD or MacOS\n    - Android, iOS or something else are not supported yet\n- SDL and SDL Image \u003e= 2.0\n\n## Installation\n\nLibrary is available as composer repository and can be \ninstalled using the following command in a root of your project.\n\n```bash\n$ composer require serafim/ffi-sdl-image\n```\n\nAdditional dependencies:\n  - Debian-based Linux: `sudo apt install libsdl2-image-2.0-0 -y`\n  - MacOS: `brew install sdl2_image`\n  - Window: Can be [downloaded from here](https://github.com/libsdl-org/SDL_image/releases)\n\n## Documentation\n\nThe library API completely supports and repeats the analogue in the C language.\n\n- [SDL2 Image official documentation](https://www.libsdl.org/projects/SDL_image/docs/index.html)\n\n## Initialization\n\nIn the case that you need a specific SDL instance, it should be passed \nexplicitly:\n\n```php\n$sdl = new Serafim\\SDL\\SDL(version: '2.28.3');\n$image = new Serafim\\SDL\\Image\\Image(sdl: $sdl);\n\n// If no argument is passed, the latest initialized\n// version will be used.\n$image = new Serafim\\SDL\\Image\\Image(sdl: null);\n```\n\n\u003e ! It is recommended to always specify the SDL dependency explicitly.\n\nTo specify a library pathname explicitly, you can add the `library` argument to\nthe `Serafim\\SDL\\Image\\Image` constructor.\n\n\u003e By default, the library will try to resolve the binary's pathname automatically.\n\n```php\n// Load library from pathname (it may be relative or part of system-dependent path)\n$image = new Serafim\\SDL\\Image\\Image(library: __DIR__ . '/path/to/library.so');\n\n// Try to automatically resolve library's pathname\n$image = new Serafim\\SDL\\Image\\Image(library: null);\n```\n\nYou can also specify the library version explicitly. Depending on this version,\nthe corresponding functions of the SDL Image will be available.\n\n\u003e By default, the library will try to resolve SDL Image version automatically.\n\n```php\n// Use v2.0.5 from string\n$image = new Serafim\\SDL\\Image\\Image(version: '2.0.5');\n\n// Use v2.6.3 from predefined versions constant\n$image = new Serafim\\SDL\\Image\\Image(version: \\Serafim\\SDL\\Image\\Version::V2_6_3);\n\n// Use latest supported version\n$image = new Serafim\\SDL\\Image\\Image(version: \\Serafim\\SDL\\Image\\Version::LATEST);\n```\n\nTo speed up the header compiler, you can use any PSR-16 compatible cache driver.\n\n```php\n$image = new Serafim\\SDL\\Image\\Image(cache: new Psr16Cache(...));\n```\n\nIn addition, you can control other preprocessor directives explicitly:\n\n```php\n$pre = new \\FFI\\Preprocessor\\Preprocessor();\n$pre-\u003edefine('true', 'false'); // happy debugging!\n\n$image = new Serafim\\SDL\\Image\\Image(pre: $pre);\n```\n\n## Example\n\n```php\nuse Serafim\\SDL\\SDL;\nuse Serafim\\SDL\\Image\\Image;\n\n$sdl = new SDL();\n$image = new Image(sdl: $sdl);\n\n$sdl-\u003eSDL_Init(SDL::SDL_INIT_EVERYTHING);\n$image-\u003eIMG_Init(Image::IMG_INIT_PNG);\n\n$surface = $image-\u003eIMG_Load(__DIR__ . '/path/to/image.png');\n$image-\u003eIMG_SaveJPG($surface, __DIR__ . '/path/to/image.jpg', quality: 80);\n\n\n$image-\u003eIMG_Quit();\n$sdl-\u003eSDL_Quit();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimarts%2Fffi-sdl-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserafimarts%2Fffi-sdl-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimarts%2Fffi-sdl-image/lists"}