get via nuget Omu.Drawing2
download dll here
add using:
using Omu.Drawing;
Image img = Imager.Crop(sourceImage, new Rectangle(x, y, width, height));
resize an image and maintain aspect ratio
Image img = Imager.Resize(sourceImage, newWidth, maxHeight, onlyResizeIfWider);
Imager.Save(path, img, Imager.GetEncoderInfo("image/gif"));
// image/gif is the MIME type for gif`
Imager.SaveJpeg(path, img);
the image remains the same size, and it is placed in the middle of the new canvas
Imager.PutOnWhiteCanvas(img, width, height))
// or
Imager.PutOnCanvas(img, width, height, Color.White))