{"id":14155790,"url":"https://github.com/qq15725/modern-gif","last_synced_at":"2025-10-03T23:15:55.134Z","repository":{"id":65776287,"uuid":"598970216","full_name":"qq15725/modern-gif","owner":"qq15725","description":"🚀 JavaScript GIF Codec.","archived":false,"fork":false,"pushed_at":"2024-12-25T10:40:03.000Z","size":15455,"stargazers_count":48,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-13T00:11:43.650Z","etag":null,"topics":["color-quantization","gif","gif-decoder","gif-encoder","gif-js","gif-optimization","gifenc","omggif"],"latest_commit_sha":null,"homepage":"https://toolpkg.com/gif","language":"TypeScript","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/qq15725.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":"2023-02-08T07:14:05.000Z","updated_at":"2025-04-07T10:38:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"b7596220-3cb6-4825-be3f-132371e0241d","html_url":"https://github.com/qq15725/modern-gif","commit_stats":{"total_commits":40,"total_committers":1,"mean_commits":40.0,"dds":0.0,"last_synced_commit":"178461569a730bc57ae0493a5f8672ae741ad2eb"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":"qq15725/starter-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qq15725%2Fmodern-gif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qq15725%2Fmodern-gif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qq15725%2Fmodern-gif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qq15725%2Fmodern-gif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qq15725","download_url":"https://codeload.github.com/qq15725/modern-gif/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843219,"owners_count":21972874,"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":["color-quantization","gif","gif-decoder","gif-encoder","gif-js","gif-optimization","gifenc","omggif"],"created_at":"2024-08-17T08:05:00.137Z","updated_at":"2025-10-03T23:15:50.090Z","avatar_url":"https://github.com/qq15725.png","language":"TypeScript","funding_links":[],"categories":["others"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003emodern-gif\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://unpkg.com/modern-gif\"\u003e\n    \u003cimg src=\"https://img.shields.io/bundlephobia/minzip/modern-gif\" alt=\"Minzip\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/modern-gif\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/modern-gif.svg\" alt=\"Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/modern-gif\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/modern-gif\" alt=\"Downloads\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/qq15725/modern-gif/issues\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/qq15725/modern-gif\" alt=\"Issues\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/qq15725/modern-gif/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/modern-gif.svg\" alt=\"License\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\n- ⚡️ Encode, Decode\n\n- 🎨 Set max colors(2 - 255)\n\n- 🦄️ Compression size\n\n- ☁️️ Web Worker\n\n- 🦾 TypeScript\n\n## Install\n\n```sh\nnpm i modern-gif\n```\n\n## Usage\n\n```ts\nimport { encode } from 'modern-gif'\n// import the workerUrl through Vite\nimport workerUrl from 'modern-gif/worker?url'\n\nconst output = await encode({\n  // workerUrl is optional\n  workerUrl,\n  width: 200,\n  height: 200,\n  frames: [\n    // CanvasImageSource | BufferSource | string\n    { data: '/example1.png', delay: 100 },\n    { data: '/example2.png', delay: 100 }\n  ],\n})\n\nconst blob = new Blob([output], { type: 'image/gif' })\nwindow.open(URL.createObjectURL(blob))\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eDecode\u003c/summary\u003e\u003cbr\u003e\n\n```ts\nimport { decode, decodeFrames } from 'modern-gif'\nimport workerUrl from 'modern-gif/worker?url'\n\nconst buffer = await window.fetch('/test.gif')\n  .then(res =\u003e res.arrayBuffer())\n\n// GIF file format data without image data\nconst gif = decode(buffer)\nconsole.log(gif)\n\n// Image data for all frames (workerUrl is optional)\nconst frames = await decodeFrames(buffer, { workerUrl })\nframes.forEach((frame) =\u003e {\n  const canvas = document.createElement('canvas')\n  canvas.width = frame.width\n  canvas.height = frame.height\n  canvas.getContext('2d').putImageData(\n    new ImageData(frame.data, frame.width, frame.height),\n    0,\n    0,\n  )\n  document.body.append(canvas)\n})\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCompression size\u003c/summary\u003e\u003cbr\u003e\n\nIt is easy to compress a gif by encoding and decoding\n\n```ts\nimport { decode, decodeFrames, encode } from 'modern-gif'\n// import the workerUrl through Vite\nimport workerUrl from 'modern-gif/worker?url'\n\nconst buffer = await window.fetch('/test.gif')\n  .then(res =\u003e res.arrayBuffer())\n\nconst gif = decode(buffer)\n// workerUrl is optional\nconst frames = await decodeFrames(buffer, { workerUrl })\nconst output = await encode({\n  // workerUrl is optional\n  workerUrl,\n  width: gif.width,\n  height: gif.height,\n  frames,\n  // lossy compression 2 - 255\n  maxColors: 255,\n})\n\nconst blob = new Blob([output], { type: 'image/gif' })\nwindow.open(URL.createObjectURL(blob))\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCDN\u003c/summary\u003e\u003cbr\u003e\n\n```html\n\u003cscript src=\"https://unpkg.com/modern-gif\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  modernGif.encode({\n    width: 200, height: 200,\n    frames: [\n      // CanvasImageSource | BufferSource | string\n      { data: '/example1.png', delay: 100 },\n      { data: '/example2.png', delay: 100 }\n    ],\n  }).then(output =\u003e {\n    const blob = new Blob([output], { type: 'image/gif' })\n    const link = document.createElement('a')\n    link.download = 'screenshot.png'\n    link.href = URL.createObjectURL(blob)\n    link.click()\n  })\n\u003c/script\u003e\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n## Types\n\nSee the [types.ts](src/types.ts)\n\n## Encode Options\n\nSee the [options.ts](src/options.ts)\n\n## Specifications\n\n[GIF89a Spec](https://www.w3.org/Graphics/GIF/spec-gif89a.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqq15725%2Fmodern-gif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqq15725%2Fmodern-gif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqq15725%2Fmodern-gif/lists"}