resize() public method

At minimum, either a height or width must be provided. If one of the two is set to null, the resize will maintain aspect ratio according to the provided dimension.
Since: 3.5.0
public resize ( integer | null $max_w, integer | null $max_h, boolean $crop = false ) : boolean | WP_Error
$max_w integer | null Image width.
$max_h integer | null Image height.
$crop boolean
return boolean | WP_Error
コード例 #1
0
	/**
	 * Test resizing an image including cropping
	 * 
	 */
	public function test_resize_and_crop() {

		$file = DIR_TESTDATA . '/images/gradient-square.jpg';

		$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
		$imagick_image_editor->load();

		$imagick_image_editor->resize( 100, 50, true );

		$this->assertEquals( array( 'width' => 100, 'height' => 50 ), $imagick_image_editor->get_size() );
	}