benwiley4000 / gif-frames

🖼 Extract frames from an animated GIF with pure JS
MIT License
170 stars 26 forks source link

Base64 Gif as input makes browser hang. #15

Closed gathanasprot closed 1 year ago

gathanasprot commented 5 years ago
 let imageBuffer  = new Buffer.from(Base64EncodedImage,'base64').toString('binary');

      gifFrames( { url: imageBuffer, frames: '0'},
          function (err, frameData) {

            console.log('err');
            console.log(err);
            if (err) {

              throw err;
            }
            frameData.forEach(function (frame) {

              console.log('frame')
              console.log(frame)
              console.log(frame.getImage())
            });
          }
      );

Browser hangs on this script, never giving any console.log output. In documentation it states that instead of an URL you can use a Memory Buffer. I am doing something wrong?

benwiley4000 commented 5 years ago

I'm wondering why you have .toString('binary'). I think you can just pass the result of Buffer.from(Base64EncodedImage,'base64') as the url parameter.

Does that work?

Also if it doesn't work, could you please share the GIF you're using so it's easier to debug? thanks!

gathanasprot commented 5 years ago

I'm wondering why you have .toString('binary'). I think you can just pass the result of Buffer.from(Base64EncodedImage,'base64') as the url parameter.

Does that work?

Also if it doesn't work, could you please share the GIF you're using so it's easier to debug? thanks!

Results are the same even without .toString('binary');

Here is the GIF as text file (in base64) : https://send.firefox.com/download/7153d3a625d9443c/#mtRXmD6r9qfdXdiphzNgYQ

It's pretty huge (approximately 7mb) mind you.

benwiley4000 commented 5 years ago

I'll take a look a bit later .. thanks for the gif!

benwiley4000 commented 5 years ago

Hey @gathanasoulias, I'm sorry, the link expired before I had a chance to download it. Would you be able to send it again somehow? I can try to download it in the next several hours.

gathanasprot commented 5 years ago

@benwiley4000 this is the new link: https://send.firefox.com/download/5844d64f97e1b826/#7TVcJ1z6syKVvpPtAfC6JA

benwiley4000 commented 5 years ago

Got it! Thank you.

martinstreicher commented 3 years ago

I am confused.

 let imageBuffer  = new Buffer.from(Base64EncodedImage,'base64').toString('binary');

Where is the data? Is Base64EncodedImage just a placeholder that should be replaced with something like transformer.result below?

    transformer = new FileReader
    transformer.readAsDataURL(image)
    transformer.result