Open lukeify opened 9 years ago
Hey LukeNZ, depending how long it takes @Sybio to merge in my pull request, I might end up taking over the project and working on my forked copy. With that said, here's a useful link that may lead you to your answer:
http://humpy77.deviantart.com/journal/Frame-Delay-Times-for-Animated-GIFs-240992090
@LukeNZ Forgot to mention a solution. Something I've used before is:
$gfe = new GifFrameExtractor\GifFrameExtractor();
$gfe->extract($Image);
$total_single_loop_duration = $total_duration = 0;
foreach ($gfe->getFrameDurations() as $duration) {
// if 0/100s add 10/100s, otherwise add original
$total_single_loop_duration += $duration == 0 ? 10 : $duration;
}
$total_duration = $total_single_loop_duration * $gfe->getLoopCount();
// Note: all these times are in hundredths of a second, to get in seconds just divide by 100
// Note: to use getLoopCount you'll have to use my pull request, otherwise you're only
// able to get timing for a single loop
Hey @gpv-dev. Thanks for the quick reply, I honestly wasn't expecting anything to come of this! If you were able to fork and maintain the repo, that'd be great. I'd be willing to help out if you needed it.
That solution makes sense, and I had actually read that article, but didn't consider the implications of simply bumping it up from 0 to 10 hundredths.
For what it's worth, you may find this interesting. It seems to take a mix of both clamped and unclamped duration of each frame, which could be a nice addition to this repo: http://justinsomnia.org/2006/10/gif-animation-duration-calculation/
@LukeNZ Nice article. I don't think I understand what you mean by clamped and un-clamped duration.
Looks like for their solution on handling 0 delay frames, they opted for 1 hundredths of a second per 0 delay frame. I prefer the upper limit at 10 hundredths of a second when setting constraints of gif duration for an application. Seems safer to me.
Nonetheless, everything done in that article should be supported by the current repo + my pull request update adding getLoopCount() (their getGIFIterations()).
I'm not even sure this repo is maintained anymore. I sure hope it is, since it could be very useful.
Can anyone please explain why this GIF returns a
getTotalDuration()
of0
? GifFrameExtractor recognizes it has frames, 117 of them, but it returns a frameDuration of 0 for each, which adds up to 0. -_-This isn't exactly helpful. I suspect it has something to do with 'Delay Time' vs. 'Unclamped Delay Time', as inspecting it with Preview on Mac shows the former to have a value of 0.1, and the latter to be 0.
Help, ideas?