I am new to C# and building a small application as personal challenge. I am handling quite a few images in the application and have come to the point where I need to get the images' sizes to calculate their proportions. All of the images are in the .png format (my favorite image format for many reasons). How would I be able to return the width and height in pixels from the file?
Asked
Active
Viewed 1,846 times
1
-
Look at [this thread](http://stackoverflow.com/questions/111345/getting-image-dimensions-without-reading-the-entire-file). You should get the idea. – Kapitán Mlíko Nov 25 '12 at 16:14
1 Answers
1
This code can help you:
BitmapImage bit = new BitmapImage(new Uri(@"C:\myImage.png"));
var h = bit.PixelHeight;
var w = bit.PixelWidth;

Heysem Katibi
- 1,808
- 2
- 14
- 29