How to disable a looping for gif image and save it in c#

Viewed 737

In my application, there is an image uploading and if a user wants to upload gif image. I need to disable looping in an image and save it, in the result gif image of a user must be played once and stop after that. Maybe I need to delete pointer from the last frame of gif image? Any ideas?

2 Answers

I found an answer, thank you all who tried to helped me.

The gif image has a set of properties which you can get if you know the specific address of a byte of each property. For example, 20737 is looping property. if this property set to 0 gif image will have infinite looping, but if set this property great than 0 gif image will be repeated infinitely. The example I placed here.

var image = System.Drawing.Image.FromFile(path)
var IsLooped = BitConverter.ToInt16(image.GetPropertyItem(20737).Value, 0) != 1;
Related