Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get image Width and Height with VB.Net

Tags:

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.

thanks.

Mike.

like image 652
Mike Avatar asked Feb 20 '13 23:02

Mike


1 Answers

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
like image 52
Hanlet Escaño Avatar answered Nov 15 '22 06:11

Hanlet Escaño