code: def create_image(size, format="RGB", add_alpha=True):
      step = 1
      half = size / 2
      # Create a new image
      image = Image.new("RGB", (size, size))
      d = ImageDraw.Draw(image)
      # Draw a red square
      d.rectangle(
          [(step, step), (half - step, half - step)],
          fill="red",
          outline=None,
          width=0,
      )
      # Draw a green circle.  In PIL, green is 00800, lime is 00ff00
      d.ellipse(
          [(half + step, step), (size - step, half - step)],
          fill="lime",
          outline=None,
          width=0,
      )
      # Draw a blue triangle
      d.polygon(
          [
              (half / 2, half + step),
              (half - step, size - step),
              (step, size - step),
          ],
          fill="blue",
          outline=None,
      )
      if add_alpha:
          # Creating a pie slice shaped 'mask' ie an alpha channel.
          alpha = Image.new("L", image.size, "white")
          d = ImageDraw.Draw(alpha)
          d.pieslice(
              [(step * 3, step * 3), (size - step, size - step)],
              0,
              90,
              fill="black",
              outline=None,
              width=0,
          )
          image.putalpha(alpha)
  
      if format == "BGR":
          return cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
      else:
          return image
  
imports: import io
  import random
  from unittest import mock
  import cv2
  import numpy
  import PIL.Image
  import pytest
  from parameterized import parameterized
  from PIL import ImageDraw
  import streamlit
  import streamlit.elements.image
  from streamlit.elements.image import _np_array_to_bytes, _PIL_to_bytes
  from streamlit.errors import StreamlitAPIException
  from streamlit.proto.Image_pb2 import ImageList
  from streamlit.runtime.memory_media_file_storage import _calculate_file_id, get_extension_for_mimetype
  from streamlit.web.server.server import MEDIA_ENDPOINT
  from tests.delta_generator_test_case import DeltaGeneratorTestCase
label_desc: Use image node_id 1 for calling a global function with example usage: create_image(size, format, add_alpha) and returns: cv2, image