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

Optimize & Refactor Crop- and ResizeCanvasModifiers (#1418)

* Refactor and simplify CropModifier::class
* Refactor and simplify ResizeCanvasModifier::class
This commit is contained in:
Oliver Vogel
2025-01-12 08:24:23 +01:00
committed by GitHub
parent e07119bc97
commit 58f0afd3c7
17 changed files with 220 additions and 274 deletions

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Intervention\Image\Tests;
use Imagick;
use ImagickException;
use ImagickPixel;
use Intervention\Image\Decoders\FilePathImageDecoder;
use Intervention\Image\Drivers\Imagick\Core;
@@ -20,6 +21,14 @@ abstract class ImagickTestCase extends BaseTestCase
);
}
/**
* Create test image with red (#ff0000) background
*
* @param int $width
* @param int $height
* @return Image
* @throws ImagickException
*/
public static function createTestImage(int $width, int $height): Image
{
$background = new ImagickPixel('rgb(255, 0, 0)');
@@ -29,6 +38,7 @@ abstract class ImagickTestCase extends BaseTestCase
$imagick->setImageType(Imagick::IMGTYPE_UNDEFINED);
$imagick->setColorspace(Imagick::COLORSPACE_SRGB);
$imagick->setImageResolution(96, 96);
$imagick->setImageBackgroundColor($background);
return new Image(
new Driver(),