/// <summary> /// 获取图片类型及宽高像素 /// 支持格式:Bmp、Gif、Jpeg、Png、Tiff、Webp、Svg、Psd、Pdf、Ico、Cur /// </summary> /// <param name="path"></param> /// <returns>图片不存在返回null</returns> public static ImageInfo GetImageInfo(string path) { if (path.IsWhiteSpace() || !File.Exists(path)) { return(null); } using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { return(FastImage.GetImageInfo(fs)); } }
/// <summary> /// 获取图片类型及宽高像素 /// 支持格式:Bmp、Gif、Jpeg、Png、Tiff、Webp、Svg、Psd、Pdf、Ico、Cur /// </summary> /// <param name="stream"></param> /// <returns>图片不存在返回null</returns> public static ImageInfo GetImageInfo(Stream stream) { return(FastImage.GetImageInfo(stream)); }