Check dimensions of image in gridview and resize before display
I am displaying images in a gridview as thumbnails restricting width and height to 150 and 100 respectively. For portrait size images they are distorted. Is there any way that I can check for image height and width so that I can display reduced in correct proportions
Re: Check dimensions of image in gridview and resize before display
VB.NET Code:
Dim img As Image
img = Image.FromFile("C:\Documents and Settings\dsakpal\My Documents\My Pictures\coding.jpg")
MessageBox.Show("Width: " & img.Width)
MessageBox.Show("Height: " & img.Height)
Re: Check dimensions of image in gridview and resize before display
Thanks for reply. Tried solution but problems encountered. Think it is because I'm reading from database record rather than from file. My code in an ItemTemplate within the Gridview is (javascript part simply so get pop-up larger image):
html Code:
<ItemTemplate>
<a href="javascript:openPopup('clcndet.aspx?rid=<%# Eval("ClcnRRecordID") %>&ccde=<%# Eval("ContribCode") %>')"><img height="100" width="150" src='<%# "images/" + Request.QueryString("ccde").ToString + "/" + Eval("ClcnRDigitalFileName") %>' alt="Select for enlarged image" /></a>
</ItemTemplate>
The Image file name is in field ClcnRDigitalFileName.
Also Image.FromFile and MessageBox.Show are not recognised in my VB.Net (is Web Development)