Can't count gif frames

Hello,

I’ve been following the forum thread on displaying an animated GIF on a Canvas (Animated Gif on Canvas) and decided to experiment by building a simple example project.

As a first step, I attempted to count the number of frames in the GIF using the code below. However, the result is always zero on both Windows and Linux (Raspberry Pi) using Xojo 2025 r2.

Am I missing something or doing something incorrectly?

I’ve attached both the GIF file and my example Xojo project for reference.

Thanks in advance for any insights!

Sub Pressed() Handles Pressed
  Dim f as FolderItem = FolderItem.ShowOpenFileDialog("image/gif")
  If f <> Nil Then
    Var pic as Picture = Picture.Open(f)
    TextArea1.Text = "Frames: " + pic.ImageCount.ToString
  End If
  
End Sub

DogGif
AnimGifRev1.zip (5.1 KB)

1 Like

My guess is that the ImageCount is not compatible with Gif but it is with Tiff.

Here is an example of a Tiff file with 6 images:
Multi_page24bpp.tif.zip (71.3 KB)

The count is 6 in this case.

2 Likes

A Xojo issue has been created in a previous forum post and can be viewed in the following link:
https://tracker.xojo.com/xojoinc/xojo/-/issues/79558

2 Likes