private static Rectangle GetCroppingRect(Rectangle rectangle) { if (rectangle.IsEmpty) { throw new ArgumentException(); } var centerPoint = Dlib.Center(rectangle); var maxDim = Math.Max(rectangle.Width, rectangle.Height); var d = (int)(Math.Round(maxDim / 2.0 * 1.5)); // add +50% return(new Rectangle( centerPoint.X - d, centerPoint.Y - d, centerPoint.X + d, centerPoint.Y + d )); }