public function ToolkitImagemagickTest::testDoubleCropping in ImageMagick 8.3
Tests that double cropping returns an image of expected dimensions.
@dataProvider providerToolkitConfiguration
Parameters
string $toolkit_id: The id of the toolkit to set up.
string $toolkit_config: The config object of the toolkit to set up.
array $toolkit_settings: The settings of the toolkit to set up.
File
- tests/
src/ Functional/ ToolkitImagemagickTest.php, line 118
Class
- ToolkitImagemagickTest
- Tests that core image manipulations work properly through Imagemagick.
Namespace
Drupal\Tests\imagemagick\FunctionalCode
public function testDoubleCropping(string $toolkit_id, string $toolkit_config, array $toolkit_settings) : void {
$this
->setUpToolkit($toolkit_id, $toolkit_config, $toolkit_settings);
$this
->prepareImageFileHandling();
// Prepare a test image.
$image = $this->imageFactory
->get('public://image-test.png');
$image
->resize(5833, 3889);
$image
->save('public://3204498-test.png');
// Process the image.
$test_image = $this->imageFactory
->get('public://3204498-test.png');
$this
->assertSame(5833, $test_image
->getWidth());
$this
->assertSame(3889, $test_image
->getHeight());
$test_image
->crop(0, 1601, 5826, 1456);
$test_image
->resize(1601, 400);
$test_image
->crop(100, 0, 1400, 400);
$test_image
->save('public://3204498-test-derived.png');
// Check the resulting image.
$derived_test_image = $this->imageFactory
->get('public://3204498-test-derived.png');
$this
->assertSame(1400, $derived_test_image
->getWidth());
$this
->assertSame(400, $derived_test_image
->getHeight());
}