I'm using Shell32 to get the Width, Height and the resolution of an Jpg image. I use GetDetailsOf to get these values. That works fine and fast, but after I want to use multi-threading I still see the same performance with 1 or 8 threads.
Is there a threadsafe way to get this information out of the .Net File object?
Thanks, Evert-Jan
With thanks to Tamás F, I used the next code, which is at least 4 times faster:
public void GetJpegImageSizeAndRes(string filename, out int width, out int height, out float res)
{
using (var sr = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
{
var sz = Image.FromStream(sr, false, false).Size;
res = Image.FromStream(sr, false, false).HorizontalResolution;
width= sz.Width;
height = sz.Height;
}
}
Thanks everyone, Evert-Jan