/** * Test resizing an image including cropping * */ public function test_resize_and_crop() { $file = DIR_TESTDATA . '/images/gradient-square.jpg'; $gd_image_editor = new WP_Image_Editor_GD( $file ); $gd_image_editor->load(); $gd_image_editor->resize( 100, 50, true ); $this->assertEquals( array( 'width' => 100, 'height' => 50 ), $gd_image_editor->get_size() ); }
public function resize($max_w, $max_h, $crop = false) { $is_animated_gif = GifFrameExtractor::isAnimatedGif($this->file); if (!$is_animated_gif) { return parent::resize($max_w, $max_h, $crop = false); } if ($this->size['width'] == $max_w && $this->size['height'] == $max_h) { return true; } $resized = $this->_resize_animated_gif($max_w, $max_h, $crop); if (!is_wp_error($resized)) { $this->image_animated_gif = $resized; return true; } elseif (is_wp_error($resized)) { return $resized; } return new WP_Error('image_resize_error', __('Image resize failed.'), $this->file); }