1
0
mirror of https://github.com/Intervention/image.git synced 2025-09-01 18:02:45 +02:00

Rename method

Image::getSize to Image::size
This commit is contained in:
Oliver Vogel
2023-10-24 19:52:21 +02:00
parent c5a73894a3
commit 9150e4bfa3
21 changed files with 26 additions and 31 deletions

View File

@@ -38,14 +38,9 @@ abstract class AbstractImage implements ImageInterface
return $this;
}
public function getSize(): SizeInterface
{
return new Rectangle($this->width(), $this->height());
}
public function size(): SizeInterface
{
return $this->getSize();
return new Rectangle($this->width(), $this->height());
}
public function modify(ModifierInterface $modifier): ImageInterface

View File

@@ -18,7 +18,7 @@ abstract class AbstractFitModifier
protected function getCropSize(ImageInterface $image): SizeInterface
{
$imagesize = $image->getSize();
$imagesize = $image->size();
$crop = new Rectangle($this->width, $this->height);
$crop = $crop->contain(

View File

@@ -22,7 +22,7 @@ abstract class AbstractPadModifier
protected function getCropSize(ImageInterface $image): SizeInterface
{
return $image->getSize()
return $image->size()
->contain($this->width, $this->height)
->alignPivotTo($this->getResizeSize($image), $this->position);
}

View File

@@ -24,7 +24,7 @@ class CropModifier implements ModifierInterface
{
$crop = new Rectangle($this->width, $this->height);
$crop->align($this->position);
$crop->alignPivotTo($image->getSize(), $this->position);
$crop->alignPivotTo($image->size(), $this->position);
foreach ($image as $frame) {
$this->cropFrame($frame, $crop);

View File

@@ -12,7 +12,7 @@ class PadDownModifier extends PadModifier
{
$resize = $this->getResizeSize($image);
return $image->getSize()
return $image->size()
->contain($resize->getWidth(), $resize->getHeight())
->alignPivotTo($resize, $this->position);
}

View File

@@ -48,8 +48,8 @@ class PlaceModifier implements ModifierInterface
protected function getPosition(ImageInterface $image, ImageInterface $watermark): PointInterface
{
$image_size = $image->getSize()->movePivot($this->position, $this->offset_x, $this->offset_y);
$watermark_size = $watermark->getSize()->movePivot($this->position);
$image_size = $image->size()->movePivot($this->position, $this->offset_x, $this->offset_y);
$watermark_size = $watermark->size()->movePivot($this->position);
return $image_size->getRelativePositionTo($watermark_size);
}

View File

@@ -9,6 +9,6 @@ class ResizeDownModifier extends ResizeModifier
{
protected function getAdjustedSize(ImageInterface $image): SizeInterface
{
return $image->getSize()->resizeDown($this->width, $this->height);
return $image->size()->resizeDown($this->width, $this->height);
}
}

View File

@@ -27,7 +27,7 @@ class ResizeModifier implements ModifierInterface
protected function getAdjustedSize(ImageInterface $image): SizeInterface
{
return $image->getSize()->resize($this->width, $this->height);
return $image->size()->resize($this->width, $this->height);
}
protected function resizeFrame(FrameInterface $frame, SizeInterface $resizeTo): void

View File

@@ -9,6 +9,6 @@ class ScaleDownModifier extends ResizeModifier
{
protected function getAdjustedSize(ImageInterface $image): SizeInterface
{
return $image->getSize()->scaleDown($this->width, $this->height);
return $image->size()->scaleDown($this->width, $this->height);
}
}

View File

@@ -9,6 +9,6 @@ class ScaleModifier extends ResizeModifier
{
protected function getAdjustedSize(ImageInterface $image): SizeInterface
{
return $image->getSize()->scale($this->width, $this->height);
return $image->size()->scale($this->width, $this->height);
}
}

View File

@@ -22,7 +22,7 @@ class CropModifier implements ModifierInterface
{
$crop = new Rectangle($this->width, $this->height);
$crop->align($this->position);
$crop->alignPivotTo($image->getSize(), $this->position);
$crop->alignPivotTo($image->size(), $this->position);
foreach ($image as $frame) {
$frame->getCore()->extentImage(

View File

@@ -12,7 +12,7 @@ class PadDownModifier extends PadModifier
{
$resize = $this->getResizeSize($image);
return $image->getSize()
return $image->size()
->contain($resize->getWidth(), $resize->getHeight())
->alignPivotTo($resize, $this->position);
}

View File

@@ -41,8 +41,8 @@ class PlaceModifier implements ModifierInterface
protected function getPosition(ImageInterface $image, Image $watermark): PointInterface
{
$image_size = $image->getSize()->movePivot($this->position, $this->offset_x, $this->offset_y);
$watermark_size = $watermark->getSize()->movePivot($this->position);
$image_size = $image->size()->movePivot($this->position, $this->offset_x, $this->offset_y);
$watermark_size = $watermark->size()->movePivot($this->position);
return $image_size->getRelativePositionTo($watermark_size);
}

View File

@@ -9,6 +9,6 @@ class ResizeDownModifier extends ResizeModifier
{
protected function getAdjustedSize(ImageInterface $image): SizeInterface
{
return $image->getSize()->resizeDown($this->width, $this->height);
return $image->size()->resizeDown($this->width, $this->height);
}
}

View File

@@ -29,6 +29,6 @@ class ResizeModifier implements ModifierInterface
protected function getAdjustedSize(ImageInterface $image): SizeInterface
{
return $image->getSize()->resize($this->width, $this->height);
return $image->size()->resize($this->width, $this->height);
}
}

View File

@@ -9,6 +9,6 @@ class ScaleDownModifier extends ResizeModifier
{
protected function getAdjustedSize(ImageInterface $image): SizeInterface
{
return $image->getSize()->scaleDown($this->width, $this->height);
return $image->size()->scaleDown($this->width, $this->height);
}
}

View File

@@ -9,6 +9,6 @@ class ScaleModifier extends ResizeModifier
{
protected function getAdjustedSize(ImageInterface $image): SizeInterface
{
return $image->getSize()->scale($this->width, $this->height);
return $image->size()->scale($this->width, $this->height);
}
}

View File

@@ -53,7 +53,7 @@ interface ImageInterface extends Traversable, Countable
*
* @return SizeInterface
*/
public function getSize(): SizeInterface;
public function size(): SizeInterface;
/**
* Return exif data of current image

View File

@@ -44,15 +44,15 @@ class AbstractImageTest extends TestCase
public function testGetSize(): void
{
$img = $this->abstractImageMock();
$this->assertInstanceOf(Rectangle::class, $img->getSize());
$this->assertEquals(300, $img->getSize()->getWidth());
$this->assertEquals(200, $img->getSize()->getHeight());
$this->assertInstanceOf(Rectangle::class, $img->size());
$this->assertEquals(300, $img->size()->getWidth());
$this->assertEquals(200, $img->size()->getHeight());
}
public function testSizeAlias(): void
{
$img = $this->abstractImageMock();
$this->assertInstanceOf(Rectangle::class, $img->getSize());
$this->assertInstanceOf(Rectangle::class, $img->size());
$this->assertEquals(300, $img->size()->getWidth());
$this->assertEquals(200, $img->size()->getHeight());
}

View File

@@ -92,7 +92,7 @@ class ImageTest extends TestCase
public function testGetSize(): void
{
$this->assertInstanceOf(Rectangle::class, $this->image->getSize());
$this->assertInstanceOf(Rectangle::class, $this->image->size());
}
public function testPickColor(): void

View File

@@ -87,7 +87,7 @@ class ImageTest extends TestCase
public function testGetSize(): void
{
$this->assertInstanceOf(Rectangle::class, $this->image->getSize());
$this->assertInstanceOf(Rectangle::class, $this->image->size());
}
public function testGetColorspace(): void