meta info
  • Title: LazZiya.ImageResize - Image Mask
  • Keywords: asp.net-core, image, resize, crop, scale, text watermark, animated, gif, conditional, frame, border, fill, mask
  • Description: Image resizing tool for .Net applications to resize images and add text/image watermark, Supports most common image types including animated gif.
  • Author: Ziya Mollamahmut
  • Date: 11-Mar-2021
  • Image: https://github.com/LazZiya/Docs/raw/master/LazZiya.ImageResize/v4.0/images/lazziya-imageresize-logo.png
  • Image-alt: LazZiya.ImageResize Logo
  • Version: v4.0

By Ziya Mollamahmut

Image Mask

Simply apply a mask over the image.

// make ellipse frame
using(var img = Image.FromFile("my-image-file.jpg")
{
    img.Mask(new Rectangle(0, 0, 300, 300), ImageFrameShape.Ellipse)
       .SaveAs("wwwroot/upload/new-image.png");
}

Original image:

Original image

Result:

Resized with frame

All methods are available with the conditional If variation.