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:
commit
e405753b85
@ -97,6 +97,7 @@ abstract class AbstractDriver implements DriverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws NotSupportedException
|
||||
* @see DriverInterface::specializeMultiple()
|
||||
*/
|
||||
public function specializeMultiple(array $objects): array
|
||||
|
@ -71,6 +71,7 @@ class Driver extends AbstractDriver
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @see DriverInterface::createAnimation()
|
||||
*/
|
||||
public function createAnimation(callable $init): ImageInterface
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ class Driver extends AbstractDriver
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @see DriverInterface::createAnimation()
|
||||
*/
|
||||
public function createAnimation(callable $init): ImageInterface
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
38
tests/Unit/Drivers/Gd/Modifiers/CoverDownModifierTest.php
Normal file
38
tests/Unit/Drivers/Gd/Modifiers/CoverDownModifierTest.php
Normal 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());
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user