Skip to content
/ gifken Public

JavaScript library that can reverse and split animated GIFs

License

Notifications You must be signed in to change notification settings

aaharu/gifken

Repository files navigation

gifken

npm version FOSSA Status

How to use

Split an animated GIF image in browser

<script type="module">
  import {reverse, split} from 'gifken'

  const imageUrl = '/01_Koch-Kurve-Sechseck-alt._Def.-2.gif'
  const response = await fetch(imageUrl)
  const buffer = await response.arrayBuffer()

  const results = await split(new Uint8Array(buffer))
  for (const result of results) {
    const img = new Image()
    img.src = URL.createObjectURL(new Blob([result], {type: 'image/gif'}))
    document.body.append(img)
  }
</script>

Reverse an animated GIF image with Node.js

const {readFileSync, writeFileSync} = require('fs')
const gifken = require('gifken')

gifken
  .reverse(readFileSync('./assets/01_Koch-Kurve-Sechseck-alt._Def.-2.gif'))
  .then(result => {
    writeFileSync('reverse.gif', result)
  })

Build

To build gifken, following tools are required

  • Node.js >=14
  • npm >=8
  • Cargo
  • wasm-bindgen
git clone *thisrepo*
cd gifken
npm install
npm run build

Similar Projects

License

MIT

FOSSA Status