NOTE: Don't put exactly 360 instead of 359.9 because it seems that the implementation makes the test and uses imageellipse instead!
Below is my Ellipse function that is sensitive to imagesetthickness function AND that creates a properly closed ellipse.

<?php
function myimageellipse($image, $x, $y, $rx, $ry, $color)
{
// We don't use imageellipse because the imagesetthickness function has
// no effect. So the better workaround is to use imagearc.
imagearc($image,$x,$y,$rx,$ry, 0,359,$color);

// If we stop here, we don't have a properly closed ellipse.
// Using imagefill at this point will flood outside the ellipse (actually arc).

// We have to close the arc to make it a real ellipse.
$cos359=0.99984769;
$sin359=-0.01745240;

$x1=round($x+$rx/2*$cos359);
$y1=round($y+$ry/2*$sin359);

$x2=round($x+$rx/2);
$y2=round($y);

// imageline is sensitive to imagesetthickness as well.
imageline($image,$x1,$y1,$x2,$y2,$color);

This will draw a 43x43 square because the border (thickness) is set to 2. *however* this is not a "regular" border of 2 pixels around the 41x41 original square!

On the left and right, there will be a thickness of 3, while there we be a thickness of 2.

If you take the imageline example, but set the thickness before to 2, this will *almost* do the trick: the left most pixel of the square will not be drawn.

To conclude:

1) do not forget that (width, height) of drawn rectangle is (x2-x1+1, y2-y1+1)2) thickness is bad implemented (or at least, the behavior i s not documented) on rectangle, as the left/right thickness is not the wanted one.3) 4*imageline() should do the trick, but after "patching" the top left pixel.