class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
Try to use image_ratio_crop instead of image_ratio. What is does is to fill the dimensions that you want with the image, keeping the ratio, and cropping the extra parts out.
You can set image_ratio_crop to true, or to a string with one or more from 'TBLR'. If you set it to true, the part of the image which is kept is at the centre of the picture. If you use T,B,L and/or R, you can choose which side or corner of the image is kept while the rest is cropped out.
Try to use image_ratio_crop instead of image_ratio. What is does is to fill the dimensions that you want with the image, keeping the ratio, and cropping the extra parts out.
You can set image_ratio_crop to true, or to a string with one or more from 'TBLR'. If you set it to true, the part of the image which is kept is at the centre of the picture. If you use T,B,L and/or R, you can choose which side or corner of the image is kept while the rest is cropped out.
I modified your picture so it explains how it works if you are to use image_ratio_crop.
See the samples to see examples of image_ratio_crop