In case you want to use an open polygon but are stuck with a PHP version prior to 7.2, a solution may be to 'backplot' your array to its original start. Say you have an array of pixels (below seperated by commas)
<?php
$arr = array();
for ($i = 0; $i < count($pixels); $i++) {
$pixel = explode(',', $pixels[$i]);
if (($pixel[0] > 0) && ($pixel[1] > 0)) {
$arr[] = $pixel[0];
$arr[] = $pixel[1];
}
}
imagepolygon($im, $arr, (count($arr) / 2), $otcolor);
?>
you can replace this by something like
<?php
$arr = array();
for ($i = 0; $i < count($pixels); $i++) {
$pixel = explode(',', $pixels[$i]);
$arr[] = $pixel[0];
$arr[] = $pixel[1];
}
for ($i = (count($pixels)-1); $i >= 0; $i--) {
$pixel = explode(',', $pixels[$i]);
$arr[] = $pixel[0];
$arr[] = $pixel[1];
}
imagepolygon($im, $arr, (count($arr) / 2), $otcolor);
?>