Page 1 of 1

Get gif duration?

Posted: Tue Aug 13, 2024 8:34 pm
by vwidmer
Is there a simple way to get the duration of a gif?

like this gif is 4secs long?

Re: Get gif duration?

Posted: Tue Aug 13, 2024 9:26 pm
by Paul
This is pretty simple using the Image library commands...

Code: Select all

UseGIFImageDecoder()

gif=LoadImage(#PB_Any,"mygif.gif")
If gif
  frames=ImageFrameCount(gif)
  If frames>1
    For idx=1 To frames
      SetImageFrame(gif,idx-1)
      delay+GetImageFrameDelay(gif)
    Next
  EndIf
  
  Debug "Frames: "+frames
  Debug "Total ms: "+delay
  
  FreeImage(gif)
EndIf

Re: Get gif duration?

Posted: Tue Aug 13, 2024 9:29 pm
by infratec
You need to read the headers of each frame and add the DelayTimes.

Ok, to late.