I am using Gifshot to generate an animation. I am successfully generating a "file". However, it seems like the encoding is off. The image that's gets generated is being generated via the following code:
var images = [
'http://i.imgur.com/2OO33vX.jpg',
'http://i.imgur.com/qOwVaSN.png',
'http://i.imgur.com/Vo5mFZJ.gif'
];
var gifshot = require('gifshot');
gifshot.createGIF(
{ 'images':images, 'numFrames': images.length },
function(obj) {
if (!obj.error) {
fs.writeFile(
'./animation.gif', obj.image, 'base64',
function(err) {
if (err) {
alert(err);
} else {
alert('Should be all good');
}
}
);
}
}
);
When the above code runs, animation.gif gets generated to my local file system (it generates a 108kb file). However, when I open it, the animation doesn't actually exist. I'm not sure what I'm doing wrong. I know that Gifshot returns a Base 64 image. I assumed that was the issue. So, I tried integrating the SO answer found here. However, that didn't work either. I'm not sure what I'm doing wrong. Any help is much appreciated.
Thanks!
Try the module base64image-to-file
var images = [
'http://i.imgur.com/2OO33vX.jpg',
'http://i.imgur.com/qOwVaSN.png',
'http://i.imgur.com/Vo5mFZJ.gif'
];
var gifshot = require('gifshot');
var base64ImageToFile = require('base64image-to-file'); //// new
gifshot.createGIF(
{ 'images':images, 'numFrames': images.length },
function(obj) {
if (!obj.error) {
base64ImageToFile(obj.image, '.', 'animation.gif', //// new
function(err) {
if (err) {
alert(err);
} else {
alert('Should be all good');
}
}
);
}
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With