Problem: you need a quick way for fitting an image in a certain size and crop without vertical or horizontal banding. No user (via all those nice js crop libraries) interaction here.
Well, first you need Imagine:
Ok, not that Imagine.
You need this Imagine. Imagine is a nice PHP library that abstracts the most common manipulation libraries to give the developer a very intuitive and fully OO compliant set of tools.
If you are working with symfony and composer, and you are, just add the dependency to your composer.json:
and run php composer.phar update.
Once your vendors and autoload are updated, you can define a simple service to do the job:
Now your image will be resized to fit the smaller dimension of the given box and then cropped to fit it perfectly.