Now I write you few functions on python which add image and text on background. Change these functions so that text be centralized (aligment), but save all the features like different colors for random words etc.
Code:
from PIL import Image, ImageDraw, ImageFont, ImageOps
import textwrap
import random

def draw_text(draw, text, font, default_text_color, text_area_width, text_area_height, start_x, start_y, shadow_offset, color_ratio=0.2, alternate_color='orange'):
  text = text.upper()
  words = text.split()
  # Determine the number of words to color differently, based on color_ratio
  num_words_to_color = max(1, int(len(words) * color_ratio))
  # Randomly pick unique words to color differently
  words_to_color = set(random.sample(words, num_words_to_color))

  lines = textwrap.wrap(text, width=text_area_width // (font.size // 2))

  y_offset = start_y
  for line in lines:
      # Break the line into words and calculate line height for consistent spacing
      line_words = line.split()
      line_height = draw.textbbox((0, 0), line, font=font)[3]

      x_offset = start_x
      for word in line_words:
          # Set word color depending on whether it's selected to be colored differently
          word_color = alternate_color if word in words_to_color else default_text_color

          # Draw shadow first
          draw.text((x_offset + shadow_offset, y_offset + shadow_offset), word, font=font, fill='black')

          # Draw the word itself
          draw.text((x_offset, y_offset), word, font=font, fill=word_color)

          bbox = draw.textbbox((x_offset, y_offset), word + ' ', font=font)  # Space included for naturally spacing words
          x_offset += bbox[2] - bbox[0]

      y_offset += line_height + shadow_offset




def add_image_and_text_to_background_with_mask6(
  background_path, overlay_image_path, mask_path, output_path,
  overlay_area_width, overlay_area_height, 
  text_area_width, text_area_height, text_start_x, text_start_y, 
  text, font_path, initial_font_size, text_color, shadow_color,
  alternate_color='orange', color_ratio=0.5):

  # Load background and images
  background = Image.open(background_path)
  overlay_image = Image.open(overlay_image_path).resize((overlay_area_width, overlay_area_height), resample=Image.Resampling.LANCZOS)
  mask_image = Image.open(mask_path).resize((overlay_area_width, overlay_area_height), resample=Image.Resampling.LANCZOS)

  # Ensure the background is the correct size (1080x1350)
  assert background.size == (1080, 1350)

  # Paste the overlay image onto the background using the mask
  background.paste(overlay_image, (50, 50), mask_image)

  # Initialize the drawing
  font = ImageFont.truetype(font_path, initial_font_size)
  draw = ImageDraw.Draw(background)

  # Set the seed for reproducibility, if needed
  # random.seed(1)  

  draw_text(draw, text, font, text_color, text_area_width, text_area_height, text_start_x, text_start_y, 2, color_ratio=color_ratio, alternate_color=alternate_color)

  # Save the resulting image
  background.save(output_path)


# Example usage
add_image_and_text_to_background_with_mask6(
    background_path='BlackBackground.jpg',
    overlay_image_path='OverlayImage.png',
    mask_path='Mask.png',
    output_path='output.jpg',
    overlay_area_width=970,
    overlay_area_height=600,
    text_area_width=820,
    text_area_height=500,
    text_start_x=130,
    text_start_y=740,
    text='Алези: Шумахер бы не хотел такого напарника, как Хэмилтон',
    font_path='PFDinItalic.ttf',
    initial_font_size=100,
    text_color='white',
    shadow_color='black',
    alternate_color='orange',  # Color for randomly selected words
    color_ratio=0.35  # Percentage of words to randomly color
)