使用 VB.Net 获取图像宽度和高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14991802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 16:41:54  来源:igfitidea点击:

Get image Width and Height with VB.Net

vb.net

提问by Mike

In VB.net I need to read through a folder full of images and get their: File name, Height in pixels and Width in pixels and assign their values to individual variables.

在 VB.net 中,我需要通读一个充满图像的文件夹并获取它们:文件名、高度(以像素为单位)和宽度(以像素为单位)并将它们的值分配给各个变量。

thanks.

谢谢。

Mike.

麦克风。

回答by Hanlet Esca?o

Try this:

尝试这个:

Imports System.IO
Imports System.Drawing
Module Module1

    Sub Main()
        Dim s As New DirectoryInfo("C:/Files")
        Dim files As FileInfo() = s.GetFiles("*.jpg")
        For Each f As FileInfo In files
            Dim bmp As New Bitmap(f.FullName)
            Console.WriteLine("Width: " & bmp.Width.ToString() + " > Height: " & bmp.Height.ToString())
        Next
        Console.Read()
    End Sub

End Module