code: def imgarray2bytes(np_array):
      """Convert image ndarray to bytes.
  
      Args:
          np_array (np.ndarray): Array to converte.
  
      Returns:
          Binary bytes of np_array.
      """
      try:
          import cv2
  
          np_array = cv2.cvtColor(np_array, cv2.COLOR_BGR2RGB)
          ret, buf = cv2.imencode(".png", np_array)
          img_bin = Image.fromarray(np.uint8(buf)).tobytes("raw")
      except ImportError:
          import io
  
          im = Image.fromarray(np_array)
          with io.BytesIO() as fp:
              im.save(fp, format="png")
              img_bin = fp.getvalue()
      return img_bin
  
imports: import numpy
  from PIL import Image
  from visualdl.proto.record_pb2 import Record
label_desc: Use image node_id 4 for calling a global function with example usage: imgarray2bytes(np_array) and returns: img_bin