= $max_line_width) { if (empty($buffer_line)) { $buffer_line .= $buffer_part; $buffer_part = ""; } array_push($message_lines, $buffer_line); $buffer_line = ""; } if ($c == ' ') { $buffer_line .= $buffer_part; $buffer_part = ""; } } if (!empty($buffer_part)) { $buffer_line .= $buffer_part; } array_push($message_lines, $buffer_line); // counting real image height for ($i = 0; $i < count($message_lines); $i++) { $h = $pad_x + imagesy($pfp) + $font_size * $i + $spacing * $i; if ($h + $font_size * 2 >= $height) { $height += $font_size + $spacing; } } $height += $font_size + $pad_x + $spacing; $image = imagecreate($width, $height); $gray_color = imagecolorallocate($image, 50, 50, 50); $black_color = imagecolorallocate($image, 0, 0, 0); $white_color = imagecolorallocate($image, 255, 255, 255); // setting the background imagefilledrectangle($image, 0, 0, $width, $height, $white_color); // setting the user's pfp imagecopy( $image, $pfp, $pad_x, $pad_x, 0, 0, imagesx($pfp), imagesy($pfp) ); // setting the username and the channel name imagettftext( $image, $font_size, 0, imagesx($pfp) + 32, imagesy($pfp) / 2 + $pad_x, $black_color, $font_path, $username ); imagettftext( $image, $font_size - 2, 0, imagesx($pfp) + 32, imagesy($pfp) / 2 + $pad_x + $font_size, $gray_color, $font_path, "in #{$channel}" ); // setting the message for ($i = 0; $i < count($message_lines); $i++) { $h = 32 + $pad_x + imagesy($pfp) + $font_size * $i + $spacing * $i; imagettftext( $image, $font_size, 0, $pad_x, $h, $black_color, $font_path, $message_lines[$i] ); } // drawing the twitch logo // setting the date imagettftext( $image, $font_size - 4, 0, $pad_x, $height - $pad_x, $gray_color, $font_path, date("F j, Y ยท G:i", $timestamp) . ' (UTC)' ); return $image; }