PNG-to-animated-GIF batch converter with PHP frontend, Python/Pillow backend, and JSON API for Figma plugin integration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* GIF Encoder API
|
|
*
|
|
* Endpoint for Figma plugin / external scripts.
|
|
* Accepts multipart or JSON requests.
|
|
*
|
|
* ── MULTIPART (recommended for Figma) ──
|
|
* POST /api.php
|
|
* Content-Type: multipart/form-data
|
|
*
|
|
* Fields:
|
|
* json: {
|
|
* "groups": {
|
|
* "animation_1": {
|
|
* "files": ["frame1.png", "frame2.png", "frame3.png"],
|
|
* "delays": [500, 200, 800],
|
|
* "loop": true
|
|
* },
|
|
* "animation_2": {
|
|
* "files": ["a.png", "b.png"],
|
|
* "delay": 300,
|
|
* "loop": false
|
|
* }
|
|
* },
|
|
* "quality": 256
|
|
* }
|
|
* files[]: (PNG file uploads)
|
|
*
|
|
* ── JSON BODY (base64 files) ──
|
|
* POST /api.php
|
|
* Content-Type: application/json
|
|
*
|
|
* {
|
|
* "files": {
|
|
* "frame1.png": "<base64 data>",
|
|
* "frame2.png": "<base64 data>"
|
|
* },
|
|
* "groups": {
|
|
* "my_gif": {
|
|
* "files": ["frame1.png", "frame2.png"],
|
|
* "delays": [500, 300],
|
|
* "loop": true
|
|
* }
|
|
* },
|
|
* "quality": 256
|
|
* }
|
|
*
|
|
* ── RESPONSE ──
|
|
* {
|
|
* "success": true,
|
|
* "batchId": "api_xxxxx",
|
|
* "results": [
|
|
* {
|
|
* "group": "animation_1",
|
|
* "success": true,
|
|
* "frames": 3,
|
|
* "url": "output/api_xxxxx/animation_1.gif",
|
|
* "download_url": "https://yourserver.com/gif-encoder/output/api_xxxxx/animation_1.gif",
|
|
* "base64": "<base64 encoded gif>"
|
|
* }
|
|
* ]
|
|
* }
|
|
*/
|
|
|
|
// Just forward to process.php — it handles the API logic
|
|
require __DIR__ . '/process.php';
|