locked
Test for Animated GIF RRS feed

  • Question

  • User175012386 posted
    i want my users to upload images.  my current framework will change image quality and resize original image and convert original image type to jpg.  i also want my users to upload animated gifs while saving the animated frames.  i don't know how to resize animated gifs and resizing while preserving the frames so i thought it easiest to test, if original image is an animated gif then just upload file without changing quality and image size.  but how do i test if image is an animated gif?

    Monday, July 24, 2006 5:50 PM

All replies

  • User1439985827 posted

    The function GetFrameCount of Bitmap returns the number of frames in the bitmap. So if it has more than 1 frame, it is animated. Here are some same methods:

    C#:

    public bool DoesImageHaveFrames(string ImagePath)
    {
    	using (Bitmap image = new Bitmap(ImagePath))
    		return image.GetFrameCount(System.Drawing.Imaging.FrameDimension.Time) > 1;
    }

     VB.NET:

    Public Function DoesImageHaveFrames(ByRef ImagePath As String) As Boolean
    	Using image As Bitmap = New Bitmap(ImagePath)
    		Return image.GetFrameCount(System.Drawing.Imaging.FrameDimension.Time) > 1
    	End Using
    End Function
     
    Saturday, July 29, 2006 10:29 PM
  • User175012386 posted
    thanks.
    Monday, July 31, 2006 8:04 AM