1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 12:18:14 +01:00
intervention_image/tests/GdTestCase.php

54 lines
1.5 KiB
PHP
Raw Normal View History

2021-11-05 15:48:16 +00:00
<?php
2024-01-16 12:01:29 +01:00
declare(strict_types=1);
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
abstract class GdTestCase extends BaseTestCase
2021-11-05 15:48:16 +00:00
{
2024-08-03 11:15:29 +02:00
public static 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-08-03 11:15:29 +02:00
static::getTestResourcePath($filename)
2021-11-05 15:48:16 +00:00
);
}
2024-08-03 11:15:29 +02:00
public static function createTestImage(int $width, int $height): Image
2023-12-06 18:39:27 +01:00
{
$gd = imagecreatetruecolor($width, $height);
imagefill($gd, 0, 0, imagecolorallocate($gd, 255, 0, 0));
return new Image(
new Driver(),
new Core([
new Frame($gd)
])
);
}
2024-08-03 11:15:29 +02:00
public static function createTestAnimation(): Image
2021-11-05 15:48:16 +00:00
{
$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
}
}