{"id":22235831,"url":"https://github.com/drawcall/gifcreator","last_synced_at":"2025-04-24T02:38:40.926Z","repository":{"id":262202484,"uuid":"886527248","full_name":"drawcall/gifcreator","owner":"drawcall","description":"A simple and lightweight node.js server-side GIF rendering tool","archived":false,"fork":false,"pushed_at":"2024-11-11T13:20:17.000Z","size":67601,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T17:18:20.229Z","etag":null,"topics":["gif","gif-creator","gifencoder","gifjs","gifski","node-gif","node-image","nodejs-image"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/drawcall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-11-11T06:13:44.000Z","updated_at":"2025-03-06T05:08:20.000Z","dependencies_parsed_at":"2024-12-13T17:12:58.641Z","dependency_job_id":null,"html_url":"https://github.com/drawcall/gifcreator","commit_stats":null,"previous_names":["drawcall/gifcreator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawcall%2Fgifcreator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawcall%2Fgifcreator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawcall%2Fgifcreator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawcall%2Fgifcreator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drawcall","download_url":"https://codeload.github.com/drawcall/gifcreator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250549235,"owners_count":21448811,"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":["gif","gif-creator","gifencoder","gifjs","gifski","node-gif","node-image","nodejs-image"],"created_at":"2024-12-03T02:31:34.312Z","updated_at":"2025-04-24T02:38:40.909Z","avatar_url":"https://github.com/drawcall.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GifCreator\n\nA simple and lightweight `Node.js` server-side GIF rendering tool. This tool utilizes `FFmpeg` to compose GIF images, offering easy operation and fast production, making it suitable for applications that require quick GIF animation generation.\n\n## Installation\n\nInstall this module via npm:\n\n```bash\n$ npm install gifcreator\n```\n\n#### About ffmpeg\n\n\u003e Please note that this package relies on ffmpeg, so you need to install ffmpeg before using it.\n\nThe methods for installing FFmpeg on various Linux distributions differ slightly. Here are the installation steps for some common Linux distributions:\n\n- How to Install and Use FFmpeg on CentOS [https://linuxize.com/post/how-to-install-ffmpeg-on-centos-7/](https://linuxize.com/post/how-to-install-ffmpeg-on-centos-7/)\n- How to Install FFmpeg on Debian [https://linuxize.com/post/how-to-install-ffmpeg-on-debian-9/](https://linuxize.com/post/how-to-install-ffmpeg-on-debian-9/)\n- How to compiling from Source on Linux [https://www.tecmint.com/install-ffmpeg-in-linux/](https://www.tecmint.com/install-ffmpeg-in-linux/)\n- How to Install FFmpeg on Windows [https://www.geeksforgeeks.org/how-to-install-ffmpeg-on-windows/](https://www.geeksforgeeks.org/how-to-install-ffmpeg-on-windows/)\n\n\n## Usage Example\n\n#### Creating a GIF Animation\n\nThe following example demonstrates how to use the GifCreator class to create a GIF animation with multiple frames and add images from a file path pattern.\n\n```javascript\nconst path = require('path');\nconst { createCanvas } = require('canvas');\nconst GifCreator = require('gifcreator');\n\nfunction createGif() {\n  const width = 500;\n  const height = 500;\n  const gifCreator = new GifCreator(width, height, true);\n  const outputPath = path.resolve(__dirname, 'output.gif');\n  gifCreator.setOutput(outputPath);\n  gifCreator.setRepeat(true);\n  gifCreator.setQuality(10);\n  gifCreator.setFrameRate(18);\n  gifCreator.on('success', () =\u003e {});\n\n  for (let i = 0; i \u003c 50; i++) {\n    const canvas = createCanvas(width, height);\n    const ctx = canvas.getContext('2d');\n\n    ctx.fillStyle = 'blue';\n    ctx.beginPath();\n    ctx.arc(50 + (i % 50) * 8, 250, 30, 0, Math.PI * 2);\n    ctx.fill();\n    ctx.save();\n    ctx.translate(250, 250);\n    ctx.rotate((i * Math.PI) / 40);\n    ctx.fillStyle = 'red';\n    ctx.fillRect(-50, -50, 100, 100);\n    ctx.restore();\n    gifCreator.addFrame(canvas);\n  }\n\n  gifCreator.start();\n}\n```\n\n#### Other uses\nGifCreator also supports image input and video input, for example:\n```javascript\nconst imagePattern = path.resolve(__dirname, 'images', 'h%d.png');\ngifCreator.addImage(imagePattern);\n// or\nconst video = path.resolve(__dirname, 'video.mp4');\ngifCreator.addVideo(video);\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/drawcall/gifcreator/blob/main/examples/demo/1.gif?raw=true\" width=\"28%\" /\u003e\n  \u003cimg src=\"https://github.com/drawcall/gifcreator/blob/main/examples/demo/2.gif?raw=true\" width=\"28%\" style=\"margin: 0 2%;\" /\u003e\n  \u003cimg src=\"https://github.com/drawcall/gifcreator/blob/main/examples/demo/3.gif?raw=true\" width=\"28%\" /\u003e\n\u003c/p\u003e\n\n## API and Documentation\n\n### Constructor\n\n#### `new GifCreator(width, height, verbose = false)`\n\n- **width**: `number` - The width of the output GIF.\n- **height**: `number` - The height of the output GIF.\n- **verbose**: `boolean` (optional) - If true, enables verbose logging. Default is `false`.\n\n### Methods\n\n#### `setOutput(outputPath)`\n\nSets the output path for the GIF.\n\n- **outputPath**: `string` - The file path where the GIF will be saved.\n\n#### `setRepeat(repeat)`\n\nSets the repeat option for the GIF.\n\n- **repeat**: `boolean` - If true, the GIF will loop indefinitely. If false, it will not loop.\n\n#### `setDelay(delay)`\n\nSets the delay between frames in the GIF.\n\n- **delay**: `number` - The delay in milliseconds.\n\n#### `setFrameRate(frameRate)`\n\nSets the frame rate for the GIF.\n\n- **frameRate**: `number` - The frame rate in frames per second.\n\n#### `setTransparent(color)`\n\nSets the transparent color for the GIF.\n\n- **color**: `string` - The color to be made transparent in the GIF.\n\n#### `setQuality(quality)`\n\nSets the quality of the GIF.\n\n- **quality**: `number` - The quality level (1-31, where 1 is the best quality).\n\n#### `setFfmpegPath()`\n\nSets the path for the FFmpeg executable.\n\n#### `addFrame(imageData)`\n\nAdds a frame to the GIF.\n\n- **imageData**: `Buffer` or `Canvas` - The image data for the frame.\n\n#### `addImage(imageFiles)`\n\nAdds images to the GIF.\n\n- **imageFiles**: `string` - The file path(s) of the images.\n\n#### `addVideo(videoPath)`\n\nAdds a video to the GIF.\n\n- **videoPath**: `string` - The file path of the video.\n\n#### `start()`\n\nStarts the FFmpeg process to create the GIF.\n\n#### `destroy()`\n\nDestroys the FFmpeg command and cleans up resources.\n\n### Events\n\n#### `success`\n\nEmitted when the FFmpeg process finishes successfully.\n\n#### `error`\n\nEmitted when there is an error during the FFmpeg process.\n\n- **Parameters**: \n  - `err`: `Error` - The error object.\n\n\n## Contributing\nGifCreator is an OPEN Open Source Project. This means that:\nIndividuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. \n\n## License\n\n[MIT LICENSE](./LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrawcall%2Fgifcreator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrawcall%2Fgifcreator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrawcall%2Fgifcreator/lists"}