From 1aea4e6567d0af4f673e353ed21bbe54644b1349 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 26 Jan 2024 23:59:59 +0530 Subject: [PATCH] Fix crop fit --- src/Manipulators/Size.php | 2 +- tests/Manipulators/SizeTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Manipulators/Size.php b/src/Manipulators/Size.php index 8d55133..298f10a 100644 --- a/src/Manipulators/Size.php +++ b/src/Manipulators/Size.php @@ -352,7 +352,7 @@ public function runCropResize(ImageInterface $image, $width, $height): ImageInte $zoom = $this->getCrop()[2]; - $image->resize($resize_width * $zoom, $resize_height * $zoom); + $image->scale((int) ($resize_width * $zoom), (int) ($resize_height * $zoom)); list($offset_x, $offset_y) = $this->resolveCropOffset($image, $width, $height); diff --git a/tests/Manipulators/SizeTest.php b/tests/Manipulators/SizeTest.php index d460b7d..f8fbdee 100644 --- a/tests/Manipulators/SizeTest.php +++ b/tests/Manipulators/SizeTest.php @@ -148,10 +148,10 @@ public function testRunResize() $mock->shouldReceive('height')->andReturn(100)->times(4); $mock->shouldReceive('crop')->andReturn($mock)->once(); $mock->shouldReceive('contain')->andReturn($mock)->once(); - $mock->shouldReceive('resize')->with(100, 100)->andReturn($mock)->times(2); + $mock->shouldReceive('resize')->with(100, 100)->andReturn($mock)->once(); $mock->shouldReceive('pad')->andReturn($mock)->once(); $mock->shouldReceive('scaleDown')->with(100, 100)->andReturn($mock)->times(1); - $mock->shouldReceive('scale')->with(100, 100)->andReturn($mock)->times(1); + $mock->shouldReceive('scale')->with(100, 100)->andReturn($mock)->times(2); }); $this->assertInstanceOf( @@ -243,7 +243,7 @@ public function testRunCropResize() $image = \Mockery::mock(ImageInterface::class, function ($mock) { $mock->shouldReceive('width')->andReturn(100)->times(4); $mock->shouldReceive('height')->andReturn(100)->times(4); - $mock->shouldReceive('resize')->with(100, 100)->andReturn($mock)->once(); + $mock->shouldReceive('scale')->with(100, 100)->andReturn($mock)->once(); $mock->shouldReceive('crop')->with(100, 100, 0, 0)->andReturn($mock)->once(); }); @@ -288,7 +288,7 @@ public function testResizeDoesRunWhenDimensionsAreTheSameAndTheCropZoomIsNotDefa $image = \Mockery::mock(ImageInterface::class, function ($mock) { $mock->shouldReceive('width')->andReturn(100); $mock->shouldReceive('height')->andReturn(100); - $mock->shouldReceive('resize')->once(); + $mock->shouldReceive('scale')->once(); $mock->shouldReceive('crop')->once()->andReturn($mock); });