-
-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathImage.alpha1.phpt
More file actions
34 lines (21 loc) · 884 Bytes
/
Image.alpha1.phpt
File metadata and controls
34 lines (21 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* Test: Nette\Utils\Image alpha channel.
* @phpExtension gd
*/
declare(strict_types=1);
use Nette\Utils\Image;
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$rectangle = Image::fromBlank(100, 100, Image::rgb(255, 255, 255, 127));
$rectangle->filledRectangle(25, 25, 74, 74, Image::rgb(255, 0, 0, 63));
$image = Image::fromBlank(200, 100, Image::rgb(0, 255, 0));
$image->place($rectangle, 50, 0, 63);
$image2 = Image::fromBlank(200, 100, Image::rgb(0, 255, 0));
$image2->place(Image::fromBlank(50, 50, Image::rgb(80, 174, 0)), 75, 25);
Assert::same($image2->toString(Image::PNG, 0), $image->toString(Image::PNG, 0));
ob_start();
$image = Image::fromBlank(200, 100, Image::rgb(255, 128, 0, 60));
$image->crop(0, 0, '60%', '60%');
$image->send(Image::PNG, 0);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha1.png'), ob_get_clean());