Gab*_*art 8 c# windows file file-properties
我希望在没有打开的情况下在磁盘上找到图像的高度/宽度,如果可能的话(出于性能原因).
图像的Windows属性窗格包含宽度,高度,位深度等信息,这使我相信它正在某处存储元数据.我如何访问此信息?
小智 5
使用System.Drawing.Image类.
Image img = Image.FromFile(fileName);
ImageFormat format = img.RawFormat;
Console.WriteLine("Image Type : "+format.ToString());
Console.WriteLine("Image width : "+img.Width);
Console.WriteLine("Image height : "+img.Height);
Console.WriteLine("Image resolution : "+(img.VerticalResolution*img.HorizontalResolution));
Console.WriteLine("Image Pixel depth : "+Image.GetPixelFormatSize(img.PixelFormat));
Console.WriteLine("Image Creation Date : "+creation.ToString("yyyy-MM-dd"));
Console.WriteLine("Image Creation Time : "+creation.ToString("hh:mm:ss"));
Console.WriteLine("Image Modification Date : "+modify.ToString("yyyy-MM-dd"));
Console.WriteLine("Image Modification Time : "+modify.ToString("hh:mm:ss"));
Run Code Online (Sandbox Code Playgroud)