Posts

Showing posts from August, 2022

Image Resize in Asp .Net Core. | Asp.Net Core 3.1 | Discover Vibes

Image
  Hello guys, let's learn how to do image resize in Asp.Net Core.   Step 1: Let's create Controller class and create its constructor and add " IHostingEnviromnet " interface. Step 2: Install " System.Drawing.Common " nuget package. Step 3: Back-end controller logic is in below. public class ImageController : Controller     {         private readonly IHostingEnvironment _hostingEnvironment;         public ImageController(IHostingEnvironment hostingEnvironment)         {             _hostingEnvironment = hostingEnvironment;         }         public IActionResult ImageResize()         {             return View();         }         [HttpPost]         public IActionResult ImageResize(IFormFile file)         {             int height = 400;             int width = 400;             string path = Path.Combine(_hostingEnvironment.WebRootPath, "Image", "resized.jpg");             Image image = Image.FromStream(file.OpenReadStream(), true, true);