As you can see in the example image, the left and right sides are 1 px wider than they should be, this is the case for every width > 1.
Wrote this function to fix that bit.. probably not a drop-in replacement though. It draws a rectangle *around* the given coordinates, for any width line.
<?php
function imagelinerectangle($img, $x1, $y1, $x2, $y2, $color, $width=1) {
imagefilledrectangle($img, $x1-$width, $y1-$width, $x2+$width, $y1-1, $color);
imagefilledrectangle($img, $x2+1, $y1-$width, $x2+$width, $y2+$width, $color);
imagefilledrectangle($img, $x1-$width, $y2+1, $x2+$width, $y2+$width, $color);
imagefilledrectangle($img, $x1-$width, $y1-$width, $x1-1, $y2+$width, $color);
}
?>