Resize an image to make a thumbnail or intermediate size.

The returned array has the file size, the image width, and image height. The filter ‘image_make_intermediate_size’ can be used to hook in and change the values of the returned array. The only parameter is the resized file path.

Signature

image_make_intermediate_size( $file, $width, $height, $crop = false )
file
 (string) File path.
width
 (int) Image width.
height
 (int) Image height.
crop
 (boolean) Optional, default is false. Whether to crop image to specified height and width or resize.
Default: false

Return

(boolean|array) False, if no image was created. Metadata array on success.

Source

function image_make_intermediate_size( $file, $width, $height, $crop = false ) {
	if ( $width || $height ) {
		$editor = wp_get_image_editor( $file );

		if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
			return false;

		$resized_file = $editor->save();

		if ( ! is_wp_error( $resized_file ) && $resized_file ) {
			unset( $resized_file['path'] );
			return $resized_file;
		}
	}
	return false;
}
WP Trac GitHub

Link here