mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
38455293f7
This test case fails with external libgd, because libgd < 2.2.4 converts palette images to truecolor (<https://github.com/libgd/libgd/issues/297>). However, even if there happens no truecolor conversion, it is not guaranteed that the palette indexes of the original and the cropped image are identical (this is, for instance, not the case with current libgd master where the bug has been fixed). Therefore we check for the expected RGBA value instead of the palette index.
42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
--TEST--
|
|
Bug #67447 (imagecrop() adds a black line when cropping)
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('gd')) {
|
|
die("skip gd extension not available\n");
|
|
}
|
|
?>
|
|
--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)
|
|
}
|