Products
Services
Contact Us

Scripts: Asp :: Asp.net drawing and image functions :: Library Article #5

Developer's Section

Get Image Dimensions in ASP.NET
By: Erobo Team Member

Hire a Developer for Related Work / Installation | $55 hr
Rating:  | Rate It:   
Average Votes: (1765)
Favorites:

Learn how to get the dimensions of any image in your server

In this article we demonstrate how to get the dimensions of any image located in your server. All you have to do is find the path of the image-- You can use Server.MapPath-- and then create an object of type System.Drawing.Image. See example below:

 Code Snippet 1


'Determine image width and height from an image in your server

Dim imgWidth 

Dim imgHeight

Dim ImagePath as String =  Server.MapPath("imagefolder/image.jpg")

'Create a new image object
System.Drawing.Image ImageObj = System.Drawing.Image.FromFile(ImagePath)

'get image width
imgWidth = ImageObj.PhysicalDimension.Width

'get image height
imgHeight = ImageObj.PhysicalDimension.Height

Response.Write( imgWidth & "<br>" & vbCrlf)

Response.Write( imgHeight & "<br>" & vbCrlf)



See other Scripts in Asp.net drawing and image functions

Submit Your Scripts:


System Message:
  • Your ASP & ASP.NET script has been sent. Please allow 48 hours for processing.


If you would like to have your ASP & ASP.NET scripts published in this section please fill out
the form below:
*Your Name or Username:
Home Town:
*Email:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]