{"id":19353619,"url":"https://github.com/benwiley4000/gif-frames","last_synced_at":"2025-04-05T06:10:20.903Z","repository":{"id":37602576,"uuid":"95393985","full_name":"benwiley4000/gif-frames","owner":"benwiley4000","description":"🖼 Extract frames from an animated GIF with pure JS","archived":false,"fork":false,"pushed_at":"2023-02-27T17:48:53.000Z","size":284,"stargazers_count":176,"open_issues_count":28,"forks_count":26,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T05:08:05.601Z","etag":null,"topics":["extract","frames","gif","gif-animation","images","pure-javascript"],"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/benwiley4000.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-06-26T00:36:52.000Z","updated_at":"2025-02-13T09:14:39.000Z","dependencies_parsed_at":"2024-06-18T13:46:13.140Z","dependency_job_id":"de06d03b-f014-44be-b154-bfa1fa242def","html_url":"https://github.com/benwiley4000/gif-frames","commit_stats":{"total_commits":62,"total_committers":3,"mean_commits":"20.666666666666668","dds":"0.16129032258064513","last_synced_commit":"aebfa81fd8acab12c7cade68ba75cf69731c3554"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwiley4000%2Fgif-frames","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwiley4000%2Fgif-frames/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwiley4000%2Fgif-frames/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwiley4000%2Fgif-frames/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benwiley4000","download_url":"https://codeload.github.com/benwiley4000/gif-frames/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294541,"owners_count":20915340,"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":["extract","frames","gif","gif-animation","images","pure-javascript"],"created_at":"2024-11-10T04:43:31.456Z","updated_at":"2025-04-05T06:10:20.877Z","avatar_url":"https://github.com/benwiley4000.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Please note that open-source maintenance is not my main focus at the moment.\n\nI will not be investing significant effort in the very near future to review and address issues on this repository. However I do want my software to be useable!\n\nIf you have an issue that must be resolved for your work, please open a pull request to fix it, and send me a direct email to make sure that I see it. I ignore most messages from GitHub these days.\n\nI'm also happy to help out if you have a question about how to use the library.\n\nMy email can be found [at the top of this commit](https://github.com/benwiley4000/cassette/commit/d1a828ac146f357adec963ccfaad56a48155b8b6.patch).\n\nKeep in mind that I have a full-time job and a personal life as well as other hobbies that have taken priority over open source, so I might not respond immediately. But don't hesitate to follow up after a few days if you think I've missed your email.\n\n# gif-frames\n\nA pure JavaScript tool for extracting GIF frames and saving to file. Works in Node or the browser. Uses [get-pixels](https://github.com/scijs/get-pixels) and [save-pixels](https://github.com/scijs/save-pixels) under the hood.\n\n[![NPM](https://nodei.co/npm/gif-frames.png)](https://npmjs.org/package/gif-frames)\n\n## Install\n\n```bash\nnpm install gif-frames\n```\n\n### CDN scripts\n\nIf you're not using npm, you can include one of these in your HTML file:\n\n* [https://unpkg.com/gif-frames?main=bundled](https://unpkg.com/gif-frames?main=bundled) (Unminified)\n* [https://unpkg.com/gif-frames?main=bundled-min](https://unpkg.com/gif-frames?main=bundled-min) (Minified)\n\n```html\n\u003c!-- unminified --\u003e\n\u003cscript src=\"https://unpkg.com/gif-frames@1.0.1?main=bundled\"\u003e\u003c/script\u003e\n\n\u003c!-- minified --\u003e\n\u003cscript src=\"https://unpkg.com/gif-frames@1.0.1?main=bundled-min\"\u003e\u003c/script\u003e\n```\n\nThis will expose `gifFrames` as a global variable.\n\n## `require('gif-frames')(options[, callback])`\n\n```javascript\nvar gifFrames = require('gif-frames');\nvar fs = require('fs');\n\ngifFrames({ url: 'image.gif', frames: 0 }).then(function (frameData) {\n  frameData[0].getImage().pipe(fs.createWriteStream('firstframe.jpg'));\n});\n```\n\n### Options:\n\n* `url` (**required**): The pathname to the file, or an [in-memory Buffer](http://nodejs.org/api/buffer.html)\n* `frames` (**required**): The set of frames to extract. Can be one of:\n  - `'all'` (gets every frame)\n  - Any valid [`Initializer`](https://github.com/smikitky/node-multi-integer-range#initializers) accepted by the [multi-integer-range library](https://github.com/smikitky/node-multi-integer-range)\n* `outputType` (*optional*, default `'jpg'`): Type to use for output (see [`type`](https://github.com/scijs/save-pixels#requiresave-pixelsarray-type-options) for `save-pixels`)\n* `quality` (*optional*): Jpeg quality (see [`quality`](https://github.com/scijs/save-pixels#requiresave-pixelsarray-type-options) for `save-pixels`)\n* `cumulative` (*optional*, default `false`): Many animated GIFs will only contain partial image information in each frame after the first. Specifying `cumulative` as `true` will compute each frame by layering it on top of previous frames. *Note: the cost of this computation is proportional to the size of the last requested frame index.*\n\nThe callback accepts the arguments `(error, frameData)`.\n\n### Returns:\n\nA `Promise` resolving to the `frameData` array (if promises are supported in the running environment)\n\n## `frameData`\n\nAn array of objects of the form:\n\n```javascript\n{\n  getImage,\n  frameIndex,\n  frameInfo\n}\n```\n\n### `getImage()`\n\nReturns one of:\n* A drawn canvas DOM element, if `options.outputType` is `'canvas'`\n* A data stream which can be piped to file output, otherwise\n\n###  `frameIndex`\n\nThe index corresponding to the frame's position in the original GIF (not necessarily the same as the frame's position in the result array)\n\n###  `frameInfo`\n\nIt is an Object with metadata of the frame. Fields:\n\nName|Type|Description\n----|-----|-----------\nx | Integer | Image Left Position\ny | Integer | Image Top Position\nwidth | Integer | Image Width\nheight | Integer | Image Height\nhas_local_palette | Boolean | Image local palette presentation flag\npalette_offset | Integer | Image palette offset\npalette_size | Integer | Image palette size\ndata_offset | Integer | Image data offset\ndata_length | Integer | Image data length\ntransparent_index | Integer | Transparent Color Index\ninterlaced | Boolean | Interlace Flag\ndelay | Integer | Delay Time (1/100ths of a second)\ndisposal | Integer | Disposal method\n\nSee [GIF spec for details](http://www.onicos.com/staff/iz/formats/gif.html)\n\n## Examples\n\nWriting selected frames to the file system in Node:\n\n```javascript\nvar gifFrames = require('gif-frames');\nvar fs = require('fs');\n\ngifFrames(\n  { url: 'image.gif', frames: '0-2,7', outputType: 'png', cumulative: true },\n  function (err, frameData) {\n    if (err) {\n      throw err;\n    }\n    frameData.forEach(function (frame) {\n      frame.getImage().pipe(fs.createWriteStream(\n        'image-' + frame.frameIndex + '.png'\n      ));\n    });\n  }\n);\n```\n\nDrawing first frame to canvas in browser (and using a `Promise`):\n\n```javascript\nvar gifFrames = require('gif-frames');\n\ngifFrames({ url: 'image.gif', frames: 0, outputType: 'canvas' })\n  .then(function (frameData) {\n    document.body.appendChild(frameData[0].getImage());\n  }).catch(console.error.bind(console));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenwiley4000%2Fgif-frames","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenwiley4000%2Fgif-frames","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenwiley4000%2Fgif-frames/lists"}