title: How to compress the image size using .NET Core?
body: <p>I am using .NET Core 2.2. In my code, I am using <strong>IFormFile</strong> to upload images. How can I compress the image size (to KB) just before it is uploaded to the server ? I search for solutions but those answers were related to <strong>Bitmap</strong> but since I am using IFormFile therefore I want solution related to it.</p>
  <p>I will internally check the image size and if its size is up to 700KB, I don't want to compress. But if it is higher, then I want to compress and upload. Sample codes would be very useful</p>
  <p><strong>I tried to use Magick.NET package. How can I make IFormFile to MagickImage type?</strong></p>
  <pre><code>foreach(IFormFile photo in Images)  
  {
    using (MagickImage mi = photo)  // Cannot implicitly convert type 
                                    //Microsoft.AspNetCore.Http.IFormFile to ImageMagick.MagickImage
     {
        mi.Format = Image.Jpeg;
        mi.Resize(40, 40);
        mi.Quality = 10;
        mi.Write(imageFile);
     }
  }
  </code></pre>