1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-16 19:58:14 +01:00

Merge branch 'main' into develop

This commit is contained in:
Oliver Vogel 2024-06-06 19:23:00 +02:00
commit e405753b85
No known key found for this signature in database
GPG Key ID: 1B19D214C02D69BB
10 changed files with 98 additions and 3 deletions

View File

@ -97,6 +97,7 @@ abstract class AbstractDriver implements DriverInterface
/**
* {@inheritdoc}
*
* @throws NotSupportedException
* @see DriverInterface::specializeMultiple()
*/
public function specializeMultiple(array $objects): array

View File

@ -71,6 +71,7 @@ class Driver extends AbstractDriver
/**
* {@inheritdoc}
*
* @throws RuntimeException
* @see DriverInterface::createAnimation()
*/
public function createAnimation(callable $init): ImageInterface

View File

@ -14,6 +14,6 @@ class CoverDownModifier extends CoverModifier
*/
public function getResizeSize(SizeInterface $size): SizeInterface
{
return $size->scaleDown($this->width, $this->height);
return $size->resizeDown($this->width, $this->height);
}
}

View File

@ -70,6 +70,7 @@ class Driver extends AbstractDriver
/**
* {@inheritdoc}
*
* @throws RuntimeException
* @see DriverInterface::createAnimation()
*/
public function createAnimation(callable $init): ImageInterface

View File

@ -14,6 +14,6 @@ class CoverDownModifier extends CoverModifier
*/
public function getResizeSize(SizeInterface $size): SizeInterface
{
return $size->scaleDown($this->width, $this->height);
return $size->resizeDown($this->width, $this->height);
}
}

View File

@ -38,6 +38,6 @@ class CoverModifier extends SpecializableModifier
*/
public function getResizeSize(SizeInterface $size): SizeInterface
{
return $size->scale($this->width, $this->height);
return $size->resize($this->width, $this->height);
}
}

View File

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Intervention\Image\Tests\Unit\Drivers\Gd\Modifiers;
use Intervention\Image\Drivers\Gd\Modifiers\CoverDownModifier;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Tests\GdTestCase;
#[RequiresPhpExtension('gd')]
#[CoversClass(\Intervention\Image\Modifiers\CoverModifier::class)]
#[CoversClass(\Intervention\Image\Drivers\Gd\Modifiers\CoverModifier::class)]
final class CoverDownModifierTest extends GdTestCase
{
public function testModify(): void
{
$image = $this->readTestImage('blocks.png');
$this->assertEquals(640, $image->width());
$this->assertEquals(480, $image->height());
$image->modify(new CoverDownModifier(100, 100, 'center'));
$this->assertEquals(100, $image->width());
$this->assertEquals(100, $image->height());
$this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90));
$this->assertColor(0, 255, 0, 255, $image->pickColor(65, 70));
$this->assertColor(0, 0, 255, 255, $image->pickColor(70, 52));
$this->assertTransparency($image->pickColor(90, 30));
}
public function testModifyOddSize(): void
{
$image = $this->createTestImage(375, 250);
$image->modify(new CoverDownModifier(240, 90, 'center'));
$this->assertEquals(240, $image->width());
$this->assertEquals(90, $image->height());
}
}

View File

@ -27,4 +27,12 @@ final class CoverModifierTest extends GdTestCase
$this->assertColor(0, 0, 255, 255, $image->pickColor(70, 52));
$this->assertTransparency($image->pickColor(90, 30));
}
public function testModifyOddSize(): void
{
$image = $this->createTestImage(375, 250);
$image->modify(new CoverModifier(240, 90, 'center'));
$this->assertEquals(240, $image->width());
$this->assertEquals(90, $image->height());
}
}

View File

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Intervention\Image\Tests\Unit\Drivers\Imagick\Modifiers;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Modifiers\CoverDownModifier;
use Intervention\Image\Tests\ImagickTestCase;
#[RequiresPhpExtension('imagick')]
#[CoversClass(\Intervention\Image\Modifiers\CoverModifier::class)]
#[CoversClass(\Intervention\Image\Drivers\Imagick\Modifiers\CoverModifier::class)]
final class CoverDownModifierTest extends ImagickTestCase
{
public function testModify(): void
{
$image = $this->readTestImage('blocks.png');
$this->assertEquals(640, $image->width());
$this->assertEquals(480, $image->height());
$image->modify(new CoverDownModifier(100, 100, 'center'));
$this->assertEquals(100, $image->width());
$this->assertEquals(100, $image->height());
$this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90));
$this->assertColor(0, 255, 0, 255, $image->pickColor(65, 70));
$this->assertColor(0, 0, 255, 255, $image->pickColor(70, 52));
$this->assertTransparency($image->pickColor(90, 30));
}
public function testModifyOddSize(): void
{
$image = $this->createTestImage(375, 250);
$image->modify(new CoverDownModifier(240, 90, 'center'));
$this->assertEquals(240, $image->width());
$this->assertEquals(90, $image->height());
}
}

View File

@ -27,4 +27,12 @@ final class CoverModifierTest extends ImagickTestCase
$this->assertColor(0, 0, 255, 255, $image->pickColor(70, 52));
$this->assertTransparency($image->pickColor(90, 30));
}
public function testModifyOddSize(): void
{
$image = $this->createTestImage(375, 250);
$image->modify(new CoverModifier(240, 90, 'center'));
$this->assertEquals(240, $image->width());
$this->assertEquals(90, $image->height());
}
}