gifff
v0.0.3
Published
Get the first frame of a Gif image
Downloads
12
Maintainers
Readme
Gif First Frame
Get the first frame of a Gif image.
Install
# yarn
yarn add gifff
# npm
npm install gifff
Usage
HTMLCanvasElement
import gifff from 'gifff/canvas'
/**
* Use `HTMLCanvasElement` to get Gif First Frame
*
* @param {string|File} file - GifHttpUrl or GifLocalFile
* @returns {Promise<Blob>} PNG Blob
*/
const blob = await gifff(Gif)
document.getElementById('img').src = URL.createObjectURL(blob)
WebAssembly
import gifff from 'gifff/wasm'
/**
* 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<string>} PNG base64
*/
const base64 = await gifff(Gif, {
wasm: WASM_PATH
})
document.getElementById('img').src = base64