Oct
22
2007
Get Image Dimensions with .NET
I wanted to get the dimensions of an image that I was going to load in a popup so that I would know how big to make the popup. I also didn’t want to open my aspjpeg component as I’m trying to keep it all in .NET
Here’s what I came up with:
Dim strPhoto As String = “/images/newPhoto.jpg”
Dim workingImage As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(strPhoto))
Dim intWidth As Integer = CInt(workingImage.PhysicalDimension.Width)
Dim intHeight As Integer = CInt(workingImage.PhysicalDimension.Height)
this will put the width and height into variables that I can play around with.