Import animated GIF as series of costumes

Finally got a basic working version of a native Snap! GIF file reader


Its very slow (as I'm still debugging it) but it should work

Please let me know if it fails on any files for you

To use - click on 1st script to load a GIF file in and then click on the 2nd one to convert the file into costumes.

Uses @pumpkinhead File Import library blocks to load the GIF file in

[update 1 19Nov20 - Known issue in not handling transparent pixels. Should no longer hang forever/report error if file contains comments. ]

[update 2 19Nov20 Transparency issue should be sorted - will now try speeding it up :slight_smile: ]

[update 3 19Nov20 Better error reporting ]

[update 4 20Nov20 Sets turbo flag at beginning and switches off at end - 3x speed of original code]
[update 4 20Nov20 Declaring it a working product :slight_smile: ]

I'd be glad to test, but it's so increadibly slow. 20 seconds? No, it's tens and tens of minutes.
NB My computer is fast enough

I said 20 secs is the time it takes to START the actual image decoding :slight_smile:

The script is in a debugging mode state

But please send me link to your file that takes tens and tens of minutes

Am I using this wrong? because I uploaded a file and clicked the long code....and it only just turns into a turtle.....

it froze on me....

Btw, what does this mean when it says:
"SW2 unexpected byte in GIF File read"???

Probably, despite its name, the imported file is not a GIF image.

But it was a GIF image---I had it as one of my pfp's once---here's the image I am trying to upload:

(but of course the forums don't animate the gifs, so you won't see it move)

It's JPG not GIF!

._. but it's animated.

GIF's ARE animated...

I'm guessing that the file is quite large and that you probably pressed the script again.

Try a smaller file if you've got one


sigh...literally all of my gifs are jpeg...


so nothings gonna work

Just my debugging method of saying that the script wasn't expecting the value it read at this point in the program

I'll make the error message more explicit

Here is an image with just one frame:
It took 11.5 mins to load it.
And it was loaded with issues:

Image looks OK with me so I must have fixed whatever bug was causing the issue in one of my updates

After limiting the UI update with turbo and, quick and dirty,
ReadGIF script pic
the frame was imported in 100s (on a low-end notebook).

Yes, now it was loaded ok and - with @dardoro's trick - for reasonable time.

Tens of minutes - I meant another gif 800x400 with several frames. Will try again now

Great project! It will be a very useful tool!

Just for those interested in the method behind this code, this is the article I've based it on

I think I've got all the little glitches out now and its about 3x faster than the original by mainly switching Turbo on at start of script and switching it off again at the end :slight_smile:

This GIF breaks after the first frame. 6bb8c71e27e8309ae2ce2a55d31a2c31