I need another way than the code below to load image's size and orientation (if any is set). I am using WPF.
There are two problems with this code:
It loads the whole image so it both takes time and memory (especially on large images)
If the image is too large, it will just crash with an unknown exception, assuming it was an out of memory one
using (FileStream imageStream = File.OpenRead(path)) { using (System.Drawing.Image img = System.Drawing.Image.FromStream(imageStream)) { Rotation imgRotation = GetImageOreintation(img);//get rotation itemData.ImageWidth = img.Width; itemData.ImageHeight = img.Height; itemData.ImageOrientation = imgRotation; if (imgRotation != Rotation.Rotate0) imgTemp.Rotation = imgRotation; } }