mirror of
https://github.com/Intervention/image.git
synced 2025-08-12 17:03:59 +02:00
Revert position behaviour of resize methods
This commit is contained in:
@@ -349,9 +349,9 @@ interface ImageInterface extends IteratorAggregate, Countable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize the boundaries of the current image to given width and height.
|
* 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
|
* An anchor position can be defined to determine where the original image
|
||||||
* image the resizing is going to happen. A background color can be passed
|
* is fixed. A background color can be passed to define the color of the
|
||||||
* to define the color of the new emerging areas.
|
* new emerging areas.
|
||||||
*
|
*
|
||||||
* @param null|int $width
|
* @param null|int $width
|
||||||
* @param null|int $height
|
* @param null|int $height
|
||||||
|
@@ -25,7 +25,7 @@ class ContainModifier extends AbstractModifier
|
|||||||
)
|
)
|
||||||
->alignPivotTo(
|
->alignPivotTo(
|
||||||
$this->getResizeSize($image),
|
$this->getResizeSize($image),
|
||||||
$this->position()
|
$this->position
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,14 +33,4 @@ class ContainModifier extends AbstractModifier
|
|||||||
{
|
{
|
||||||
return new Rectangle($this->width, $this->height);
|
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(
|
->alignPivotTo(
|
||||||
$this->getResizeSize($image),
|
$this->getResizeSize($image),
|
||||||
$this->position()
|
$this->position
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,17 +24,7 @@ class ResizeCanvasModifier extends AbstractModifier
|
|||||||
return (new Rectangle($width, $height))
|
return (new Rectangle($width, $height))
|
||||||
->alignPivotTo(
|
->alignPivotTo(
|
||||||
$image->size(),
|
$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))
|
return (new Rectangle($width, $height))
|
||||||
->alignPivotTo(
|
->alignPivotTo(
|
||||||
$image->size(),
|
$image->size(),
|
||||||
$this->position()
|
$this->position
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ class ResizeCanvasModifierTest extends TestCase
|
|||||||
{
|
{
|
||||||
$image = $this->createTestImage(1, 1);
|
$image = $this->createTestImage(1, 1);
|
||||||
$this->assertColor(255, 0, 0, 255, $image->pickColor(0, 0));
|
$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(1, $image->width());
|
||||||
$this->assertEquals(2, $image->height());
|
$this->assertEquals(2, $image->height());
|
||||||
$this->assertColor(255, 255, 0, 255, $image->pickColor(0, 0));
|
$this->assertColor(255, 255, 0, 255, $image->pickColor(0, 0));
|
||||||
|
@@ -46,7 +46,7 @@ class ResizeCanvasModifierTest extends TestCase
|
|||||||
{
|
{
|
||||||
$image = $this->createTestImage(1, 1);
|
$image = $this->createTestImage(1, 1);
|
||||||
$this->assertColor(255, 0, 0, 255, $image->pickColor(0, 0));
|
$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(1, $image->width());
|
||||||
$this->assertEquals(2, $image->height());
|
$this->assertEquals(2, $image->height());
|
||||||
$this->assertColor(255, 255, 0, 255, $image->pickColor(0, 0));
|
$this->assertColor(255, 255, 0, 255, $image->pickColor(0, 0));
|
||||||
|
Reference in New Issue
Block a user