mirror of
https://github.com/Intervention/image.git
synced 2025-08-19 20:21:32 +02:00
Rename methods
Rename fit() to cover() and fitDown() to coverDown()
This commit is contained in:
@@ -8,7 +8,7 @@ use Intervention\Image\Interfaces\SizeInterface;
|
||||
* @property int $width
|
||||
* @property int $height
|
||||
*/
|
||||
class FitDownModifier extends FitModifier
|
||||
class CoverDownModifier extends CoverModifier
|
||||
{
|
||||
public function getResizeSize(SizeInterface $size): SizeInterface
|
||||
{
|
@@ -11,7 +11,7 @@ use Intervention\Image\Interfaces\SizeInterface;
|
||||
* @method SizeInterface getResizeSize(ImageInterface $image)
|
||||
* @method SizeInterface getCropSize(ImageInterface $image)
|
||||
*/
|
||||
class FitModifier extends DriverSpecializedModifier
|
||||
class CoverModifier extends DriverSpecializedModifier
|
||||
{
|
||||
public function apply(ImageInterface $image): ImageInterface
|
||||
{
|
@@ -8,7 +8,7 @@ use Intervention\Image\Interfaces\SizeInterface;
|
||||
* @property int $width
|
||||
* @property int $height
|
||||
*/
|
||||
class FitDownModifier extends FitModifier
|
||||
class CoverDownModifier extends CoverModifier
|
||||
{
|
||||
public function getResizeSize(SizeInterface $size): SizeInterface
|
||||
{
|
@@ -10,7 +10,7 @@ use Intervention\Image\Interfaces\SizeInterface;
|
||||
* @method SizeInterface getResizeSize(ImageInterface $image)
|
||||
* @method SizeInterface getCropSize(ImageInterface $image)
|
||||
*/
|
||||
class FitModifier extends DriverSpecializedModifier
|
||||
class CoverModifier extends DriverSpecializedModifier
|
||||
{
|
||||
public function apply(ImageInterface $image): ImageInterface
|
||||
{
|
@@ -51,8 +51,8 @@ use Intervention\Image\Modifiers\DrawPixelModifier;
|
||||
use Intervention\Image\Modifiers\DrawPolygonModifier;
|
||||
use Intervention\Image\Modifiers\DrawRectangleModifier;
|
||||
use Intervention\Image\Modifiers\FillModifier;
|
||||
use Intervention\Image\Modifiers\FitDownModifier;
|
||||
use Intervention\Image\Modifiers\FitModifier;
|
||||
use Intervention\Image\Modifiers\CoverDownModifier;
|
||||
use Intervention\Image\Modifiers\CoverModifier;
|
||||
use Intervention\Image\Modifiers\FlipModifier;
|
||||
use Intervention\Image\Modifiers\FlopModifier;
|
||||
use Intervention\Image\Modifiers\GammaModifier;
|
||||
@@ -504,21 +504,21 @@ final class Image implements ImageInterface, Countable
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see ImageInterface::fit()
|
||||
* @see ImageInterface::cover()
|
||||
*/
|
||||
public function fit(int $width, int $height, string $position = 'center'): ImageInterface
|
||||
public function cover(int $width, int $height, string $position = 'center'): ImageInterface
|
||||
{
|
||||
return $this->modify(new FitModifier($width, $height, $position));
|
||||
return $this->modify(new CoverModifier($width, $height, $position));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see ImageInterface::fitDown()
|
||||
* @see ImageInterface::coverDown()
|
||||
*/
|
||||
public function fitDown(int $width, int $height, string $position = 'center'): ImageInterface
|
||||
public function coverDown(int $width, int $height, string $position = 'center'): ImageInterface
|
||||
{
|
||||
return $this->modify(new FitDownModifier($width, $height, $position));
|
||||
return $this->modify(new CoverDownModifier($width, $height, $position));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -335,24 +335,24 @@ interface ImageInterface extends IteratorAggregate, Countable
|
||||
* @param string $position
|
||||
* @return ImageInterface
|
||||
*/
|
||||
public function fit(int $width, int $height, string $position = 'center'): ImageInterface;
|
||||
public function cover(int $width, int $height, string $position = 'center'): ImageInterface;
|
||||
|
||||
/**
|
||||
* Same as fit() but do not exceed the original image size
|
||||
* Same as cover() but do not exceed the original image size
|
||||
*
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @param string $position
|
||||
* @return ImageInterface
|
||||
*/
|
||||
public function fitDown(int $width, int $height, string $position = 'center'): ImageInterface;
|
||||
public function coverDown(int $width, int $height, string $position = 'center'): ImageInterface;
|
||||
|
||||
/**
|
||||
* Padded resizing means that the original image is scaled until it fits the
|
||||
* defined target size with unchanged aspect ratio. The original image is
|
||||
* not scaled up but only down.
|
||||
*
|
||||
* Compared to the fit() method, this method does not create cropped areas,
|
||||
* Compared to the cover() method, this method does not create cropped areas,
|
||||
* but possibly new empty areas on the sides of the result image. These are
|
||||
* filled with the specified background color.
|
||||
*
|
||||
|
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace Intervention\Image\Modifiers;
|
||||
|
||||
class FitDownModifier extends FitModifier
|
||||
class CoverDownModifier extends CoverModifier
|
||||
{
|
||||
}
|
@@ -6,7 +6,7 @@ use Intervention\Image\Geometry\Rectangle;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Interfaces\SizeInterface;
|
||||
|
||||
class FitModifier extends AbstractModifier
|
||||
class CoverModifier extends AbstractModifier
|
||||
{
|
||||
public function __construct(
|
||||
public int $width,
|
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace Intervention\Image\Tests\Drivers\Gd\Modifiers;
|
||||
|
||||
use Intervention\Image\Modifiers\FitModifier;
|
||||
use Intervention\Image\Modifiers\CoverModifier;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
use Intervention\Image\Tests\Traits\CanCreateGdTestImage;
|
||||
|
||||
/**
|
||||
* @requires extension gd
|
||||
* @covers \Intervention\Image\Modifiers\FitModifier
|
||||
* @covers \Intervention\Image\Modifiers\CoverModifier
|
||||
*/
|
||||
class FitModifierTest extends TestCase
|
||||
class CoverModifierTest extends TestCase
|
||||
{
|
||||
use CanCreateGdTestImage;
|
||||
|
||||
@@ -19,7 +19,7 @@ class FitModifierTest extends TestCase
|
||||
$image = $this->createTestImage('blocks.png');
|
||||
$this->assertEquals(640, $image->width());
|
||||
$this->assertEquals(480, $image->height());
|
||||
$image->modify(new FitModifier(100, 100, 'center'));
|
||||
$image->modify(new CoverModifier(100, 100, 'center'));
|
||||
$this->assertEquals(100, $image->width());
|
||||
$this->assertEquals(100, $image->height());
|
||||
$this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90));
|
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace Intervention\Image\Tests\Drivers\Imagick\Modifiers;
|
||||
|
||||
use Intervention\Image\Modifiers\FitModifier;
|
||||
use Intervention\Image\Modifiers\CoverModifier;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
use Intervention\Image\Tests\Traits\CanCreateImagickTestImage;
|
||||
|
||||
/**
|
||||
* @requires extension imagick
|
||||
* @covers \Intervention\Image\Modifiers\FitModifier
|
||||
* @covers \Intervention\Image\Modifiers\CoverModifier
|
||||
*/
|
||||
class FitModifierTest extends TestCase
|
||||
class CoverModifierTest extends TestCase
|
||||
{
|
||||
use CanCreateImagickTestImage;
|
||||
|
||||
@@ -19,7 +19,7 @@ class FitModifierTest extends TestCase
|
||||
$image = $this->createTestImage('blocks.png');
|
||||
$this->assertEquals(640, $image->width());
|
||||
$this->assertEquals(480, $image->height());
|
||||
$image->modify(new FitModifier(100, 100, 'center'));
|
||||
$image->modify(new CoverModifier(100, 100, 'center'));
|
||||
$this->assertEquals(100, $image->width());
|
||||
$this->assertEquals(100, $image->height());
|
||||
$this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90));
|
Reference in New Issue
Block a user