Skip to content

Commit

Permalink
Fix crop fit
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jan 26, 2024
1 parent 9e28ec5 commit 1aea4e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Manipulators/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions tests/Manipulators/SizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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);
});

Expand Down

0 comments on commit 1aea4e6

Please sign in to comment.