xref: /PHP-8.2/ext/gd/tests/bug67447.phpt (revision a375d547)
1--TEST--
2Bug #67447 (imagecrop() adds a black line when cropping)
3--EXTENSIONS--
4gd
5--FILE--
6<?php
7// true color
8$image = imagecreatetruecolor(500, 500);
9$red = imagecolorallocate($image, 255, 0, 0);
10imagefill($image, 0, 0, $red);
11$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
12var_dump(imagecolorat($cropped, 249, 249) === $red);
13imagedestroy($image);
14imagedestroy($cropped);
15
16// palette
17$image = imagecreate(500, 500);
18imagecolorallocate($image, 0, 0, 255); // first palette color = background
19$red = imagecolorallocate($image, 255, 0, 0);
20imagefill($image, 0, 0, $red);
21$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
22var_dump(imagecolorsforindex($cropped, imagecolorat($cropped, 249, 249)));
23imagedestroy($image);
24imagedestroy($cropped);
25?>
26--EXPECT--
27bool(true)
28array(4) {
29  ["red"]=>
30  int(255)
31  ["green"]=>
32  int(0)
33  ["blue"]=>
34  int(0)
35  ["alpha"]=>
36  int(0)
37}
38