How do I reliably get an image dimensions in .NET without loading the image?

后端 未结 5 2008
猫巷女王i
猫巷女王i 2020-12-01 16:04

I know how to get the size (x,y) of an image

Image.FromFile(\"cat.jpg\").Size

BUT that requires loading the image from memory.

When

5条回答
  •  庸人自扰
    2020-12-01 16:31

    You can just use Image.FromStream(Stream, bool, bool) with "false" 2nd and 3rd parameter to avoid loading file into memory.

提交回复
热议问题