Get File Info

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2008
Posts: 75
Reputation: mansi sharma is an unknown quantity at this point 
Solved Threads: 0
mansi sharma mansi sharma is offline Offline
Junior Poster in Training

Get File Info

 
0
  #1
Aug 11th, 2009
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.



  1. Imports System.IO
  2.  
  3. Public Class Form1
  4. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5. Try
  6. Dim sFileSize As String
  7. Dim FS As System.IO.FileInfo = New System.IO.FileInfo("C:\Documents and Settings\Mansi\Desktop\Image.jpg")
  8. sFileSize = FS.Length.ToString
  9. MsgBox(sFileSize)
  10.  
  11. Catch ex As Exception
  12. MsgBox(ex.Message)
  13. End Try
  14. End Sub
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,437
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 624
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Get File Info

 
0
  #2
Aug 11th, 2009
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.
  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2. Dim fName As String = "C:\picture.bmp"
  3. Dim img As Image = Image.FromFile(fName)
  4. Dim pixelHeight As Integer = img.Size.Height
  5. Dim pixelWidth As Integer = img.Size.Width
  6. Dim physicalHeight As Decimal = img.Size.Height / img.VerticalResolution
  7. Dim physicalWidth As Decimal = img.Size.Width / img.HorizontalResolution
  8. System.Diagnostics.Debugger.Break()
  9. img.Dispose()
  10. End Sub
Last edited by sknake; Aug 11th, 2009 at 4:12 pm.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 75
Reputation: mansi sharma is an unknown quantity at this point 
Solved Threads: 0
mansi sharma mansi sharma is offline Offline
Junior Poster in Training

Re: Get File Info

 
0
  #3
Aug 13th, 2009
Thx for the above answer.Can u plz also tell me,how to do also get the file type?
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 75
Reputation: mansi sharma is an unknown quantity at this point 
Solved Threads: 0
mansi sharma mansi sharma is offline Offline
Junior Poster in Training

Re: Get File Info

 
0
  #4
Aug 15th, 2009
thcx very much...I will start a new thread for file type
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 754 | Replies: 3
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC