2021-11-05 15:48:16 +00:00
|
|
|
<?php
|
|
|
|
|
2024-01-16 12:01:29 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2024-03-10 10:00:06 +01:00
|
|
|
namespace Intervention\Image\Tests;
|
2021-11-05 15:48:16 +00:00
|
|
|
|
2024-05-09 09:58:10 +02:00
|
|
|
use Intervention\Image\Decoders\FilePathImageDecoder;
|
2023-11-20 14:21:40 +01:00
|
|
|
use Intervention\Image\Drivers\Gd\Core;
|
|
|
|
use Intervention\Image\Drivers\Gd\Driver;
|
2021-11-05 15:48:16 +00:00
|
|
|
use Intervention\Image\Drivers\Gd\Frame;
|
2023-11-20 14:21:40 +01:00
|
|
|
use Intervention\Image\Image;
|
2021-11-05 15:48:16 +00:00
|
|
|
|
2024-03-10 10:00:06 +01:00
|
|
|
abstract class GdTestCase extends BaseTestCase
|
2021-11-05 15:48:16 +00:00
|
|
|
{
|
2023-12-06 18:29:28 +01:00
|
|
|
public function readTestImage($filename = 'test.jpg'): Image
|
2021-11-05 15:48:16 +00:00
|
|
|
{
|
2024-05-09 09:58:10 +02:00
|
|
|
return (new Driver())->specialize(new FilePathImageDecoder())->decode(
|
2024-03-10 10:13:45 +01:00
|
|
|
$this->getTestResourcePath($filename)
|
2021-11-05 15:48:16 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-06 18:39:27 +01:00
|
|
|
public function createTestImage(int $width, int $height): Image
|
|
|
|
{
|
|
|
|
$gd = imagecreatetruecolor($width, $height);
|
|
|
|
imagefill($gd, 0, 0, imagecolorallocate($gd, 255, 0, 0));
|
|
|
|
|
|
|
|
return new Image(
|
|
|
|
new Driver(),
|
|
|
|
new Core([
|
|
|
|
new Frame($gd)
|
|
|
|
])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-05 15:48:16 +00:00
|
|
|
public function createTestAnimation(): Image
|
|
|
|
{
|
|
|
|
$gd1 = imagecreatetruecolor(3, 2);
|
|
|
|
imagefill($gd1, 0, 0, imagecolorallocate($gd1, 255, 0, 0));
|
|
|
|
$gd2 = imagecreatetruecolor(3, 2);
|
|
|
|
imagefill($gd2, 0, 0, imagecolorallocate($gd1, 0, 255, 0));
|
|
|
|
$gd3 = imagecreatetruecolor(3, 2);
|
|
|
|
imagefill($gd3, 0, 0, imagecolorallocate($gd1, 0, 0, 255));
|
|
|
|
|
2023-11-20 14:21:40 +01:00
|
|
|
return new Image(
|
|
|
|
new Driver(),
|
|
|
|
new Core([
|
|
|
|
new Frame($gd1),
|
|
|
|
new Frame($gd2),
|
|
|
|
new Frame($gd3),
|
|
|
|
])
|
|
|
|
);
|
2021-11-05 15:48:16 +00:00
|
|
|
}
|
|
|
|
}
|