Image Size?

  • Thread starter Thread starter perspolis
  • Start date Start date
P

perspolis

Hi
I have an Image. I want to know how much is size of an Image in KB?

thanks in advance
 
Do you have an Image object or an image in a file.

If you have a file it's pretty easy:
int kilobytes = (new FileInfo( @"c:\image.jpg" )).Length / 1024;

If you have an image object it's harder to figure out as you'll need to
"save it" before you can know what size it is.

MemoryStream ms = new MemoryStream();
image.Save(ms, ImageFormat.Png); // change this to what format you need
int kilobytes = ms.Length / 1024;
ms.Close();
 

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

Back
Top