Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a gif image without interval #41

Open
sivamani-s opened this issue May 20, 2019 · 0 comments
Open

How to create a gif image without interval #41

sivamani-s opened this issue May 20, 2019 · 0 comments

Comments

@sivamani-s
Copy link

sivamani-s commented May 20, 2019

When i add delay it working fine if i missed the delay it through the error of image can't able to create

letimages = ['urls'] console.log('images =', images); await delay(4000, {value: '馃'}); const encoder = new GIFEncoder(1000, 1000); encoder.createReadStream().pipe(fs.createWriteStream(activity_time+'_frames_'+total_frames+'.gif')); encoder.start(); encoder.setRepeat(0); // 0 for repeat, -1 for no-repeat encoder.setDelay(500); // frame delay in ms encoder.setQuality(10); // image quality. 10 is default. const canvas = createCanvas(1000, 1000); const ctx = canvas.getContext('2d'); await delay(300, {value: '馃'}); const image = await new Promise(async (resolve,reject)=>{ for(let i=0; i<images.length; i++){ console.log('image url ',images[i].url); var data = await download_images_from_url(images[i].url); // function return's image binary data var img = new Canvas.Image; img.src = data; ctx.drawImage(img, 0, 0, 1000, 1000); await delay(500, {value: '馃'}); encoder.addFrame(ctx); if(i==(images.length)-1){ resolve('success'); } } }) encoder.finish(); console.log('image created')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant