I want to get the width & height of the image file..

Mine code is currently getting the file size, I also want to get the width & height.How to get width & height,kindly help me.

Imports System.IO

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim sFileSize As String
            Dim FS As System.IO.FileInfo = New System.IO.FileInfo("C:\Documents and Settings\Mansi\Desktop\Image.jpg")
            sFileSize = FS.Length.ToString
            MsgBox(sFileSize)

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Recommended Answers

All 3 Replies

You have two sets of sizes for a picture --- the physical size of the image (if you were to print it and not grow/shrink/stretch the image) and the pixel size.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim fName As String = "C:\picture.bmp"
		Dim img As Image = Image.FromFile(fName)
		Dim pixelHeight As Integer = img.Size.Height
		Dim pixelWidth As Integer = img.Size.Width
		Dim physicalHeight As Decimal = img.Size.Height / img.VerticalResolution
		Dim physicalWidth As Decimal = img.Size.Width / img.HorizontalResolution
		System.Diagnostics.Debugger.Break()
		img.Dispose()
	End Sub

Thx for the above answer.Can u plz also tell me,how to do also get the file type?

thcx very much...I will start a new thread for file type

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.