views:

751

answers:

1

Hi guys

Link this post I want to be able to read an image files height and width without reading in the whole file into memory.

In the post Frank Krueger mentions there is a way of doing this with some WPF Imaging classes. Any idea on how to do this??

Cheers Anthony

+3  A: 

This should do it:

var bitmapFrame = BitmapFrame.Create(new Uri(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg"), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
var width = bitmapFrame.PixelWidth;
var height = bitmapFrame.PixelHeight;

HTH, Kent

Kent Boogaart
Cheers I'll give thiis a good and let you know how I go.
vdhant
Works a treat, thanks.
vdh_ant
You beat me to it Kent. :-)
Frank Krueger