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.
You can use image_ratio_crop for your first example. For the second one, you will need to set the sizes dynamically, reading image_src_x and image_src_y before calling process()Reply
Examples:
4:3 (1.33) ratio
from 800 x 725 to 800 x 600
from 800 x 900 to 800 x 600
4:4 ratio
from 800 x 900 to 800 x 800
from 800 x 725 to 725 x 725
Thx
I'll make a function for class to do that. I'll post here when it will be ready!