sole / Animated_GIF

Javascript library for creating animated GIFs
https://sole.github.io/Animated_GIF
225 stars 53 forks source link

Iteration #33

Open siddharthnaik7 opened 7 years ago

siddharthnaik7 commented 7 years ago

Hi, I am trying to iterate the GIF only once. I am setting repeat = null for the same, which renders me the gif with only one iteration. This works well on pc browser. But when I save the image and export to my smart phone the default gif launcher of the phone, iterates the gif infinitely. How can I achieve a single iteration?

sole commented 7 years ago

It might be an issue with the GIF player in the phone if it works nicely in the browser. Can you provide an example image or code that generates the image?

siddharthnaik7 commented 7 years ago

Hi,

I have written the following code:

$scope.CreateGIF = function (){ var delay=100; function run(){ if(ol>=op) return; var objDiv = cc[ol][0].childNodes[1]; html2canvas(objDiv, { onrendered: function(canvas) { var imgElem = document.createElement("img"); var pngImage = canvas.toDataURL("img/png"); imgElem.setAttribute('src',pngImage); ag.addFrame(imgElem); } }); if(ol < op){ if(ol==(op-1)){ sid = true; } ol++; setTimeout(run, delay); console.log("After timeout......"); } console.log("After if ol<op"); } run(); console.log("After run......"); return false; }

and used following to generate the gif,

ag.getBase64GIF(function(image) { console.log("After Entering getBase64gif " + image); });

Also, please find attached the gif that I am trying to get.

This gif will work for single interation on laptop/pc browsers, but when you transfer to your smart phone, and view it in your default phone gallery, it will iterate continuously.

Kindly, let me know if there is any solution or way out for this issue.

(One other thing, how can we increase the gif speed, i.e frame rate, As, you can see, the gif frame speed/interval speed is very slow)

Thanks - Siddharth dodo

siddharthnaik7 commented 7 years ago

Hi,

Also, I am capturing 121 images(64-bit-png-data-urls) from the animation and passing these urls sequentially to addframe() function. Is this process causing the gif to run slowly? ( I have kept delay 0).

Kindly, guide me on this too.

Thanks - Siddharth