Mark Chidlow
Mark Chidlow

Reputation: 1472

How do I convert file to image in .NET Core?

.NET 4.6 etc I would do something like this...

var image = System.Drawing.Image.FromFile(filePath);

I have an uploaded file (IFormFile file)

If this is an image (png or jpeg) I need to determine the image dimensions.

I'm not sure what library I should be looking at.

Thanks.

Update

OK so .NET Core does not include image processing but there are a number of third-party libraries available - these are described here

Upvotes: 4

Views: 5499

Answers (1)

Kenneth D'hoe
Kenneth D'hoe

Reputation: 159

Using library: https://github.com/JimBobSquarePants/ImageSharp

using (FileStream stream = File.OpenRead("foo.jpg"))
    {
        Image image = new Image(stream);
    }

Upvotes: 6

Related Questions