http://codex.wordpress.org/Class_Reference/WP_Image_Editor
http://codex.wordpress.org/Function_Reference/wp_get_image_editor
$image = wp_get_image_editor( 'cool_image.jpg' );
if ( ! is_wp_error( $image ) ) {
$image->rotate( 90 );
$image->resize( 300, 300, true );
$image->save( 'cool_image.jpg' );
}
Repalce cool_image.jpg with a variable holding the path to the image you want to edit. Not a copy and paste solution but should put u on the right track. There is a crop function.
crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false );
//Crops Image.