changed the resize and centering function to allow for any ratio