我有这段代码,用于读取上传的文件,但我需要获取图像的尺寸,不确定可以使用什么代码。
HttpFileCollection collection = _context.Request.Files;
for (int i = 0; i < collection.Count; i++)
{
HttpPostedFile postedFile = collection[i];
Stream fileStream = postedFile.InputStream;
fileStream.Position = 0;
byte[] fileContents = new byte[postedFile.ContentLength];
fileStream.Read(fileContents, 0, postedFile.ContentLength);
我可以正确获取文件,但是如何检查它的图像尺寸(宽度和大小)呢?