mirror of
https://github.com/Intervention/image.git
synced 2025-01-17 20:28:21 +01:00
Revert position behaviour of resize methods
This commit is contained in:
parent
2fe03aeba7
commit
3b7238f7a8
@ -349,9 +349,9 @@ interface ImageInterface extends IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Resize the boundaries of the current image to given width and height.
|
||||
* An anchor position can be defined to determine from what point of the
|
||||
* image the resizing is going to happen. A background color can be passed
|
||||
* to define the color of the new emerging areas.
|
||||
* An anchor position can be defined to determine where the original image
|
||||
* is fixed. A background color can be passed to define the color of the
|
||||
* new emerging areas.
|
||||
*
|
||||
* @param null|int $width
|
||||
* @param null|int $height
|
||||
|
@ -25,7 +25,7 @@ class ContainModifier extends AbstractModifier
|
||||
)
|
||||
->alignPivotTo(
|
||||
$this->getResizeSize($image),
|
||||
$this->position()
|
||||
$this->position
|
||||
);
|
||||
}
|
||||
|
||||
@ -33,14 +33,4 @@ class ContainModifier extends AbstractModifier
|
||||
{
|
||||
return new Rectangle($this->width, $this->height);
|
||||
}
|
||||
|
||||
protected function position(): string
|
||||
{
|
||||
return strtr($this->position, [
|
||||
'left' => 'right',
|
||||
'right' => 'left',
|
||||
'top' => 'bottom',
|
||||
'bottom' => 'top',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class PadModifier extends ContainModifier
|
||||
)
|
||||
->alignPivotTo(
|
||||
$this->getResizeSize($image),
|
||||
$this->position()
|
||||
$this->position
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -24,17 +24,7 @@ class ResizeCanvasModifier extends AbstractModifier
|
||||
return (new Rectangle($width, $height))
|
||||
->alignPivotTo(
|
||||
$image->size(),
|
||||
$this->position()
|
||||
$this->position
|
||||
);
|
||||
}
|
||||
|
||||
protected function position(): string
|
||||
{
|
||||
return strtr($this->position, [
|
||||
'left' => 'right',
|
||||
'right' => 'left',
|
||||
'top' => 'bottom',
|
||||
'bottom' => 'top',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class ResizeCanvasRelativeModifier extends ResizeCanvasModifier
|
||||
return (new Rectangle($width, $height))
|
||||
->alignPivotTo(
|
||||
$image->size(),
|
||||
$this->position()
|
||||
$this->position
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class ResizeCanvasModifierTest extends TestCase
|
||||
{
|
||||
$image = $this->createTestImage(1, 1);
|
||||
$this->assertColor(255, 0, 0, 255, $image->pickColor(0, 0));
|
||||
$image->modify(new ResizeCanvasModifier(null, 2, 'ff0', 'top'));
|
||||
$image->modify(new ResizeCanvasModifier(null, 2, 'ff0', 'bottom'));
|
||||
$this->assertEquals(1, $image->width());
|
||||
$this->assertEquals(2, $image->height());
|
||||
$this->assertColor(255, 255, 0, 255, $image->pickColor(0, 0));
|
||||
|
@ -46,7 +46,7 @@ class ResizeCanvasModifierTest extends TestCase
|
||||
{
|
||||
$image = $this->createTestImage(1, 1);
|
||||
$this->assertColor(255, 0, 0, 255, $image->pickColor(0, 0));
|
||||
$image->modify(new ResizeCanvasModifier(null, 2, 'ff0', 'top'));
|
||||
$image->modify(new ResizeCanvasModifier(null, 2, 'ff0', 'bottom'));
|
||||
$this->assertEquals(1, $image->width());
|
||||
$this->assertEquals(2, $image->height());
|
||||
$this->assertColor(255, 255, 0, 255, $image->pickColor(0, 0));
|
||||
|
Loading…
x
Reference in New Issue
Block a user