OK, this might be overkill, but you could use something like the Fruml ImageTools (and before you ask, yes, I wrote them ).
How it works is quite simple: you define a transformation to be applied to an image in an array, then pass that to ImageTools, which transforms the image and caches it.
$crop_transformation = array(
array('crop', array('width' => 300, 'height' => 300)),
$data = $image_tool->process(array(
'source' => dirname(__FILE__) . '/example.jpg',
'chain' => $crop_transformation
echo '<img src="'. $data['path'] . '" width="'. $data['width'] . '" height="'. $data['height'] . '" alt="" />';
Why use such a verbose tool for cropping an image? Well, if you later want to do more than just crop, you can easily add new transformations:
$grayscale_transformation = array(
array('resize', array('width' => 400, 'keep_aspect' => true, 'shrink_only' => true)),
array('margin', array('global' => 2, 'bgcolor' => 'ffffff')),
array('border', array('width' => 1, 'color' => 'B0B2B4', 'enlarge' => true))
Documentation is severely lacking although if you want to give it a go, I'll be glad to help out with any questions you may have.
I'll stop plugging my project now