DEV Community

MICHAEL-MAURICE
MICHAEL-MAURICE

Posted on

Resize Images in asp.Net

I was doing a task today, and part of it was that I was uploading images..but there was a problem that would happen if the user uploaded a large image. I want to control the size of the image that I came from the user because my database is arrogant. this ..
The first thing I need to do is check the size of the image before I do it and save it. This is how I compare the length of the image (array of bytes) with the length I need, even if it is larger than it. Do not allow the user to upload this image.
The second thing is that I resize the image that I came to before I save it, and I found two packages that do this
1- SixLabors.ImageSharp, and you can read more about it here: https://www.nuget.org/packages/SixLabors.ImageSharp/2.0.0?_src=template
2- System.Drawing.Common, and you can read more about it here:-
https://www.nuget.org/packages/System.Drawing.Common/6.0.0?_src=template
And they are both, through which you can specify the width and height of your image, and this is how you can let the user upload any image, regardless of its size....

Top comments (0)