【问题标题】:Getting the resolution of an image [duplicate]获取图像的分辨率[重复]
【发布时间】:2012-06-29 01:37:46
【问题描述】:

可能重复:
Get the resolution of a jpeg image using C# and the .NET Environment?

在我正在编码的批量图像下载器中,我使用 WebClient (DownloadFile) 来保存来自给定 url 的图像。有没有一种简单的方法来获得这些图像的分辨率?如果WebClient不能,文件保存后如何获取分辨率?

【问题讨论】:

    标签: c# image webclient resolution


    【解决方案1】:

    如果从WebClient下载图片后保存,可以使用如下:

    Image img = Image.FromFile(@"image.png");
    Console.WriteLine(img.Width + "x" + img.Height);
    

    这将为您提供图像的宽度 x 高度,例如 1920x1080。

    【讨论】:

      【解决方案2】:

      要获取 DPI,请使用以下命令:

      Image image = Image.FromFile("image.jpg");
      image.HorizontalResolution;
      

      对于其他的东西,例如高度、宽度和大小,查看this stackoverflow question,它有很多很好的答案,(包括我的:D)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-27
        • 1970-01-01
        • 2014-11-20
        相关资源
        最近更新 更多