Cover, Contain and Crop Geometry
Resizing to an exact box forces a choice. Cover computes scale as the larger of targetWidth/sourceWidth and targetHeight/sourceHeight, fills the frame and crops the overflow; contain uses the smaller ratio and leaves letterbox bars. Stretch ignores the ratio and distorts faces. A focal point shifts the crop window, clamped so it never samples outside the source bitmap.
Rounding is a real source of off-by-one crops. Compute the crop rectangle in floating point, round the origin down and the size up, then clamp to the source bounds; otherwise a 4:5 crop from a 4032 by 3024 photo loses a row and the ratio drifts. For batch work, store the crop as fractions of width and height so the recipe applies at every resolution.