C#獲取gif幀數blog
/// <summary> /// 獲取gif幀數 /// </summary> /// <param name="gifBytes"></param> /// <returns></returns> public static int GetGifFrameNum(string etc, byte[] gifBytes) { try { if (etc == ".gif") { MemoryStream ms = new MemoryStream(gifBytes); Image gif = Image.FromStream(ms); FrameDimension fd = new FrameDimension(gif.FrameDimensionsList[0]); int count = gif.GetFrameCount(fd); ms.Dispose(); gif.Dispose(); return count; } else { return 1; } } catch (Exception ex) { LogHelper.WriteLog(ex); return 0; } }