https://github.com/friendlymatthew/gif
GIF parser and renderer.
https://github.com/friendlymatthew/gif
gif
Last synced: 4 months ago
JSON representation
GIF parser and renderer.
- Host: GitHub
- URL: https://github.com/friendlymatthew/gif
- Owner: friendlymatthew
- License: mit
- Created: 2024-10-13T19:58:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-02T21:42:37.000Z (over 1 year ago)
- Last Synced: 2026-01-13T10:19:27.759Z (5 months ago)
- Topics: gif
- Language: Rust
- Homepage:
- Size: 79.1 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gif
This crate aims to provide an interface that parses and decompresses GIF files. It exposes a simple API with 2
functions: one for parsing bytes into a compressed GIF data stream, and another for decompressing the stream into a list
of image frames.
This repository also contains a crate to render GIFs. It provides a command-line executable that
uses [`minifb`](https://github.com/emoon/rust_minifb) to render pixels.
`gif` aims to decode any GIF from [GIPHY](https://giphy.com). Any deviation from Giphy's rendering should be
considered a bug.
## Grammar
### Legend
The following legend defines the symbols used in this grammar:
| Symbol | Definition |
|--------|--------------------------|
| `<>` | grammar word |
| `::=` | defines symbol |
| `*` | zero or more occurrences |
| `+` | one or more occurrences |
| `\|` | alternate element |
| `[]` | optional element |
### The Grammar
` ::= Header * Trailer`
- ` ::= Logical Screen Descriptor [Global Color Table]`
- ` ::= | `
- ` ::= [Graphic Control Extension] `
- ` ::= | Plain Text Extension`
- ` ::= Image Descriptor [Local Color Table] Image Data`
- ` ::= Application Extension | Comment Extension`
## Fuzz
`gif` uses an [AFL](https://en.wikipedia.org/wiki/American_Fuzzy_Lop_(software)) fuzzer to assert correctness. GIFs that
crash are stored in `/tests` for the purpose of running
integration tests. To fuzz, simply run the `./fuzz.sh` shell script.
## Profile
This project uses [samply](https://github.com/mstange/samply) to profile the code. Run `./profile.sh` to run a
profile. Make sure to pass in a GIF file.
For example:
```bash
./profile.sh ./sample_gifs/shrek.gif
```
## Reading
https://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp
https://web.archive.org/web/20050217131148/http://www.danbbs.dk/~dino/whirlgif/lzw.html
https://www.w3.org/Graphics/GIF/spec-gif89a.txt