react-native-pixel-gif
v1.0.5
Published
Parse Gif to ImageData for React Native
Downloads
10
Maintainers
Readme
react-native-pixel-gif
Parse Gif to ImageData for React Native.
Installation
$ npm install react-native-pixel-gif
For RN >= 0.65, run npm install react-native-blob-util
.
For RN < 0.65, run npm install [email protected]
, and patch manually to fix: with react-native-web product build will export 'URIUtil' (reexported as 'URIUtil') was not found.
var pixelGif= require('react-native-pixel-gif');
console.log(pixelGif); //object
API
pixelGif.parse(file
) -> promise.then(images
)
return images
is Array contains one or more ImageData
.
var file= 'https://59naga.github.io/fixtures/animated.GIF';
pixelGif.parse(file).then(function(images){
var i= 0;
console.log(images.loopCount); // 0(Infinite)
var nextImage= function(){
var imageData= images[i++];
if(imageData==null) return;
console.log(imageData);
nextImage();
}
nextImage();
});
// { width: 73, height: 73, x: 0, y: 0, has_local_palette: false, palette_offset: 13, data_offset: 818, data_length: 393, transparent_index: null, interlaced: false, delay: 1000, disposal: 0, data: <Uint8Array ..> }
// { width: 73, height: 73, x: 0, y: 0, has_local_palette: false, palette_offset: 13, data_offset: 1229, data_length: 387, transparent_index: null, interlaced: false, delay: 900, disposal: 0, data: <Uint8Array ..> }
// { width: 73, height: 73, x: 0, y: 0, has_local_palette: false, palette_offset: 13, data_offset: 1634, data_length: 393, transparent_index: null, interlaced: false, delay: 800, disposal: 0, data: <Uint8Array ..> }
// ...
images
can be resized and also keep property e.g.delay
byresizeImageDatas
of react-native-pixel-util.
See
- react-native-pixel-image
- react-native-pixel-util
- react-native-pixel-gif
- react-native-pixel-png
- react-native-pixel-jpg
- react-native-pixel-bmp
- react-native-pixel-webp
- pixel-to-ansi
- pixel-to-svg