Added function to center the images after scaling