-
Notifications
You must be signed in to change notification settings - Fork 7.8k
/
Copy pathbug67447.phpt
37 lines (36 loc) · 946 Bytes
/
bug67447.phpt
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
35
36
37
--TEST--
Bug #67447 (imagecrop() adds a black line when cropping)
--EXTENSIONS--
gd
--FILE--
<?php
// true color
$image = imagecreatetruecolor(500, 500);
$red = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $red);
$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
var_dump(imagecolorat($cropped, 249, 249) === $red);
imagedestroy($image);
imagedestroy($cropped);
// palette
$image = imagecreate(500, 500);
imagecolorallocate($image, 0, 0, 255); // first palette color = background
$red = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $red);
$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
var_dump(imagecolorsforindex($cropped, imagecolorat($cropped, 249, 249)));
imagedestroy($image);
imagedestroy($cropped);
?>
--EXPECT--
bool(true)
array(4) {
["red"]=>
int(255)
["green"]=>
int(0)
["blue"]=>
int(0)
["alpha"]=>
int(0)
}