Skip to content

stacksjs/ts-gif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Social Card of this repo

npm version GitHub Actions Commitizen friendly

ts-gif

A TypeScript library for reading, writing, and manipulating GIF images

Features

  • ๐ŸŽจ Complete GIF Support: Full support for GIF87a and GIF89a specifications
  • ๐Ÿ–ผ๏ธ Frame Management: Create and manipulate multi-frame animated GIFs
  • ๐ŸŽฏ Precise Control: Fine-grained control over frame delays, disposal methods, and transparency
  • ๐ŸŒˆ Color Tables: Support for both global and local color palettes
  • ๐Ÿ”„ Animation: Full control over animation loops and timing
  • ๐Ÿ’ช Typed: Written in TypeScript with full type safety
  • โšก Efficient: Optimized for performance with minimal memory footprint
  • ๐Ÿงฐ Simple API: Easy-to-use interface for both basic and advanced GIF operations

Get Started

Installation

npm install ts-gif
# bun i ts-gif

Usage

import { Reader, Writer } from 'ts-gif'

// Reading a GIF
const reader = new Reader(buffer)
console.log(`Dimensions: ${reader.width}x${reader.height}`)
console.log(`Number of frames: ${reader.numFrames()}`)

// Writing a GIF
const writer = new Writer(buffer, width, height, {
  palette: globalPalette,
  loop: 0 // 0 = loop forever
})

// Add frames
writer.addFrame(0, 0, width, height, pixelData, {
  delay: 100, // 100ms delay
  disposal: 2, // Clear frame before next
  transparent: null
})

// Finalize the GIF
writer.end()

Testing

bun test

Changelog

Please see our releases page for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discussions on GitHub

For casual chit-chat with others using this package:

Join the Stacks Discord Server

Postcardware

โ€œSoftware that is free, but hopes for a postcard.โ€ We love receiving postcards from around the world showing where ts-gif is being used! We showcase them on our website too.

Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States ๐ŸŒŽ

Credits

Thanks to Dean McNamee for the original omggif library.

Sponsors

We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.

License

The MIT License (MIT). Please see LICENSE for more information.

Made with ๐Ÿ’™

About

TypeScript implementation of a performant GIF encoder & decoder.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 3

  •  
  •  
  •