An exact canvas, with the whole image kept
Your image is scaled to fit inside the width and height you enter, centred, and the space left over is filled with a colour you pick.
The output is exactly the dimensions you asked for, every time. Nothing is cropped and nothing is stretched, because the image is scaled by a single factor chosen so that it fits entirely within the box. When the image and the canvas have different shapes, the difference shows up as even bands of your chosen colour on two sides — at the top and bottom for a wide image in a square canvas, or at the sides for a tall one.