Getting the width/height of an image

N

Nathan Sokalski

I need to get the width and height of a GIF image through code. I need this
info so that I can set the width and height properties of Image and
ImageButton objects. System.IO.File.GetAttributes(imagelocation) only seem
to return properties that all files have, which does not include width and
height. How can I get this info? Any help would be appreciated. Thanks.
 
H

Herfried K. Wagner [MVP]

Nathan Sokalski said:
I need to get the width and height of a GIF image through code. I need this
info so that I can set the width and height properties of Image and
ImageButton objects. System.IO.File.GetAttributes(imagelocation) only seem
to return properties that all files have, which does not include width and
height. How can I get this info?

Load the file using 'Image.LoadFrom' and check the 'Image' object's 'Height'
and 'Width' properties.
 
N

Nathan Sokalski

I seem to be having trouble doing this. Do you have a small example? Thanks.
 
H

Herfried K. Wagner [MVP]

Nathan Sokalski said:
I seem to be having trouble doing this. Do you have a small example?
Thanks.

\\\
Dim i As Image = Image.FromFile("C:\WINDOWS\Angler.bmp")
MsgBox(i.Width.ToString() & " " & i.Height.ToString())
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top