Reputation: 7122
I need to get the dimensions of an image that is uploaded as an IFormFile.
I am trying to do it like this:
// where userFileUpload is an IFormFile:
using (var fileStream = new FileStream(filePath, FileMode.Create))
{
await userFileUpload.CopyToAsync(fileStream);
using (var img = System.Drawing.Image.FromStream(fileStream))
{
// TODO: Get dimensions of the image
}
}
But I am getting an error saying 'the type name 'Image' could not be found in System.Drawing.
But according to this Microsoft Doc, it should be there.
Is there a better way of getting the image dimensions?
Thanks!
Upvotes: 0
Views: 241
Reputation: 8479
But I am getting an error saying 'the type name 'Image' could not be found in System.Drawing.
Microsoft has released System.Drawing.Common
as a NuGet. You need to download it first.
Install-Package System.Drawing.Common -Version 4.7.0
Upvotes: 1