Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lijialiang/gifff

Get the first frame of a Gif image.
https://github.com/lijialiang/gifff

canvas webassembly

Last synced: 8 days ago
JSON representation

Get the first frame of a Gif image.

Awesome Lists containing this project

README

        

# Gif First Frame ![](https://img.shields.io/npm/v/gifff?style=flat-square) ![](https://img.shields.io/npm/l/gifff?style=flat-square)

Get the first frame of a Gif image.

## Install

```sh
# yarn
yarn add gifff
# npm
npm install gifff
```

## Usage

### HTMLCanvasElement

```ts
import gifff from 'gifff/canvas'

/**
* Use `HTMLCanvasElement` to get Gif First Frame
*
* @param {string|File} file - GifHttpUrl or GifLocalFile
* @returns {Promise} PNG Blob
*/
const blob = await gifff(Gif)
document.getElementById('img').src = URL.createObjectURL(blob)
```

[Playground](https://jsbin.com/mowejon)

### WebAssembly

```ts
import gifff from 'gifff/wasm'

/**
* Use `WebAssembly` to get Gif First Frame
*
* @param {string|File} file - GifHttpUrl or GifLocalFile
* @param {undefined|Object} options
* @param {undefined|string} options.wasm WASM File Url
* @returns {Promise} PNG base64
*/
const base64 = await gifff(Gif, {
wasm: WASM_PATH
})
document.getElementById('img').src = base64
```

[Playground](https://jsbin.com/segunap)

## LICENSE

[MIT](LICENSE)