使用 VB.Net 获取图像宽度和高度 [英] Get image Width and Height with VB.Net

查看:37
本文介绍了使用 VB.Net 获取图像宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

谢谢.

迈克.

推荐答案

试试这个:

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

这篇关于使用 VB.Net 获取图像宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆