return;
} else {
- y1v = y1h + 1;
- y2v = y2h - 1;
- gdImageLine(im, x1h, y1h, x2h, y1h, color);
- gdImageLine(im, x1h, y2h, x2h, y2h, color);
- gdImageLine(im, x1v, y1v, x1v, y2v, color);
- gdImageLine(im, x2v, y1v, x2v, y2v, color);
+ if (x1 == x2 || y1 == y2) {
+ gdImageLine(im, x1, y1, x2, y2, color);
+ } else {
+ y1v = y1h + 1;
+ y2v = y2h - 1;
+ gdImageLine(im, x1h, y1h, x2h, y1h, color);
+ gdImageLine(im, x1h, y2h, x2h, y2h, color);
+ gdImageLine(im, x1v, y1v, x1v, y2v, color);
+ gdImageLine(im, x2v, y1v, x2v, y2v, color);
+ }
}
}
--- /dev/null
+--TEST--
+Bug #53154 (Zero-height rectangle has whiskers)
+--SKIPIF--
+<?php
+if (!extension_loaded('gd')) die('skip gd extension not available');
+?>
+--FILE--
+<?php
+$im = imagecreatetruecolor(100, 10);
+$red = imagecolorallocate($im, 255, 0, 0);
+imagerectangle($im, 5, 5, 95, 5, $red);
+var_dump(imagecolorat($im, 5, 4) !== $red);
+var_dump(imagecolorat($im, 5, 6) !== $red);
+var_dump(imagecolorat($im, 95, 4) !== $red);
+var_dump(imagecolorat($im, 95, 6) !== $red);
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)