using the smaller of the two dimensions as basis for the circle radius

This way, the circle "mask" always fits _inside_ the image bounds and also works for images that are not square.