function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $r, $color) {
// рисуем два прямоугольника без углов
imagefilledrectangle($im, $x1+$r, $y1, $x2-$r, $y2, $color);
imagefilledrectangle($im, $x1, $y1+$r, $x2, $y2-$r, $color);
// рисуем круги в углах
imagefilledellipse($im, $x1+$r, $y1+$r, $r*2, $r*2, $color);
imagefilledellipse($im, $x2-$r, $y1+$r, $r*2, $r*2, $color);
imagefilledellipse($im, $x1+$r, $y2-$r, $r*2, $r*2, $color);
imagefilledellipse($im, $x2-$r, $y2-$r, $r*2, $r*2, $color);
}