xref: /PHP-7.3/ext/gd/tests/bug77200.phpt (revision 209e37db)
1--TEST--
2Bug #77200 (imagecropauto(…, GD_CROP_SIDES) crops left but not right)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6if (!GD_BUNDLED) die('skip upstream bugfix has not been released');
7?>
8--FILE--
9<?php
10
11$orig = imagecreatetruecolor(8, 8);
12$red = imagecolorallocate($orig, 255, 0, 0);
13$green = imagecolorallocate($orig, 0, 255, 0);
14$blue = imagecolorallocate($orig, 0, 0, 255);
15
16imagefilledrectangle($orig, 0, 0, 3, 3, $green); // tl
17imagefilledrectangle($orig, 4, 0, 7, 3, $red);   // tr
18imagefilledrectangle($orig, 0, 4, 3, 7, $green); // bl
19imagefilledrectangle($orig, 4, 4, 7, 7, $blue);  // br
20
21$cropped = imagecropauto($orig, IMG_CROP_SIDES);
22var_dump(imagesx($cropped));
23
24imagefilledrectangle($orig, 0, 0, 3, 3, $red);   // tl
25imagefilledrectangle($orig, 4, 0, 7, 3, $green); // tr
26imagefilledrectangle($orig, 0, 4, 3, 7, $blue);  // bl
27imagefilledrectangle($orig, 4, 4, 7, 7, $green); // br
28
29$cropped = imagecropauto($orig, IMG_CROP_SIDES);
30var_dump(imagesx($cropped));
31
32?>
33===DONE===
34--EXPECT--
35int(4)
36int(4)
37===DONE===
38