943,915 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 2959
  • VB.NET RSS
Aug 11th, 2009
0

Get File Info

Expand Post »
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.



VB.NET Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 17
Solved Threads: 0
Junior Poster in Training
mansi sharma is offline Offline
75 posts
since Apr 2008
Aug 11th, 2009
0

Re: Get File Info

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.
vb.net Syntax (Toggle Plain Text)
  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.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 13th, 2009
0

Re: Get File Info

Thx for the above answer.Can u plz also tell me,how to do also get the file type?
Reputation Points: 17
Solved Threads: 0
Junior Poster in Training
mansi sharma is offline Offline
75 posts
since Apr 2008
Aug 15th, 2009
0

Re: Get File Info

thcx very much...I will start a new thread for file type
Reputation Points: 17
Solved Threads: 0
Junior Poster in Training
mansi sharma is offline Offline
75 posts
since Apr 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Problem by writting the sql statement
Next Thread in VB.NET Forum Timeline: Need help with code!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC