2021-11-05 15:48:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Intervention\Image\Tests\Traits;
|
|
|
|
|
2023-11-20 14:21:40 +01:00
|
|
|
use Intervention\Image\Drivers\Gd\Core;
|
2021-11-05 15:48:16 +00:00
|
|
|
use Intervention\Image\Drivers\Gd\Decoders\FilePathImageDecoder;
|
2023-11-20 14:21:40 +01:00
|
|
|
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
|
|
|
|
|
|
|
trait CanCreateGdTestImage
|
|
|
|
{
|
2023-12-06 18:29:28 +01:00
|
|
|
public function readTestImage($filename = 'test.jpg'): Image
|
2021-11-05 15:48:16 +00:00
|
|
|
{
|
2023-11-20 14:21:40 +01:00
|
|
|
return (new FilePathImageDecoder())->handle(
|
2021-12-01 19:12:25 +01:00
|
|
|
$this->getTestImagePath($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
|
|
|
}
|
|
|
|
}
|