C# 获取图像的分辨率
可能重复:C# 获取图像的分辨率,c#,image,webclient,resolution,C#,Image,Webclient,Resolution,可能重复: 在我正在编写的批处理图像下载程序中,我使用WebClient(下载文件)保存来自给定URL的图像。有没有一种简单的方法来获得这些图像的分辨率?如果WebClient无法保存,保存文件后如何获得分辨率?如果从WebClient下载图像后保存图像,可以使用以下方法: Image img = Image.FromFile(@"image.png"); Console.WriteLine(img.Width + "x" + img.Height); Image image = Image
在我正在编写的批处理图像下载程序中,我使用WebClient(下载文件)保存来自给定URL的图像。有没有一种简单的方法来获得这些图像的分辨率?如果WebClient无法保存,保存文件后如何获得分辨率?如果从WebClient下载图像后保存图像,可以使用以下方法:
Image img = Image.FromFile(@"image.png");
Console.WriteLine(img.Width + "x" + img.Height);
Image image = Image.FromFile("image.jpg");
image.HorizontalResolution;
这将为您提供图像的宽度x高度,例如1920x1080。要获得DPI,请使用以下方法:
Image img = Image.FromFile(@"image.png");
Console.WriteLine(img.Width + "x" + img.Height);
Image image = Image.FromFile("image.jpg");
image.HorizontalResolution;
对于其他事物,如高度、宽度和大小,视图有很多很好的答案(包括我的:D)