image_resize() with blank space [closed]

First of all pay attention that image_resize() function is deprecated! Use wp_get_image_editor() instead of it. This function will return an instance of WP_Image_Editor class (or WP_Error if some issues appear during loading your image). This class has resize method which accepts three arguments: desired width, desired height and crop flag.

Sample usage:

$editor = wp_get_image_editor( '/path/to/file.png' );
if ( !is_wp_error( $editor ) ) {
    $editor->resize( $desired_width, $desired_height, true ); // true - do crop, false - don't crop
}

Back to your question. Unfortunately there is no way to do what you want to do. Your image aspect ratio doesn’t equal to desired aspect ratio, that is why whitespace appears. If you crop the image, you will loose parts of your image from top and bottom, but in this case you won’t see whitespaces…