- Add System.Drawing.Common Nuget to your project.
2. Convert the source image to a byte array.
3. Create a source image bitmap using the source stream.
4. Create an empty target image bitmap with desired dimensions.
5. using Graphics.DrawImage method and passing arguments source image bitmap, target image rectangle, rectangle which needs to cropped from source and graphics unit. Draw the source rectangle on the target image.
6. Save the target cropped image to a file.
csharpsamples → cropimage