Retrieving Image information

G

Guest

Is there anyway that I can obtain information about an image file such as a
..jpg before I display it onto a screen. In other words, I would like to
obtain the image size so I can dynamically place it on the screen. I like to
set the width and height values according to what the size of the image is. I
do not know whtat the size is at the time, because I will pick up the image
file to what the user wants displayed. I want to display that image correctly
as is...

Thanks in advance..
 
S

Siva M

This is one way:

Image i = Bitmap.FromFile(@"c:\myImage.jpg");
Console.WriteLine (i.Height.ToString());
Console.WriteLine (i.Width.ToString());
i.Dispose();

Is there anyway that I can obtain information about an image file such as a
..jpg before I display it onto a screen. In other words, I would like to
obtain the image size so I can dynamically place it on the screen. I like to
set the width and height values according to what the size of the image is.
I
do not know whtat the size is at the time, because I will pick up the image
file to what the user wants displayed. I want to display that image
correctly
as is...

Thanks in advance..
 
B

Bruce Barker

if you don't specify a height or width, the browser uses the actuals.

-- bruce (sqlwork.com)
 
G

Guest

but the page can display quicker if the height and width are specified - it
can allocate the space before getting the image
 
B

Bruce Barker

true, but if you are using typical asp.net webforms, rendering performance
is not much of an issue, look at those viewstate sizes.

-- bruce (sqlwork.com)
 

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

Top