Image resize based on aspect ratio by adding background

Hi I add GD functionality to resize the image based on the aspect ratio of it by adding background