private function writeText(&$im, $x1, $y1, $x2, $y2, $message) { if (self::$white === null) { self::$white = ImageColorAllocate($im, 255, 255, 255); } if (self::$black === null) { self::$black = ImageColorAllocate($im, 0, 0, 0); } imagefilledrectangle($im, $x1, $y1, $x2, $y2, self::$black); $box = imagettfbbox(self::$fontsize, 0, TN_FONT, $message); $width = $box[4] - $box[0]; $height = $box[1] - $box[7]; $left = $x1 + ($x2 - $x1) / 2.0 - $width / 2; $top = $y1 + ($y2 - $y1) / 2.0 + $height / 2; imagettftext($im, 9, 0, $left, $top, self::$white, TN_FONT, $message); }