(img, image_format)
return img_bytes
Get image encoded bytes from numpy array.

     Note: use lossless PNG compression to test perfect reconstruction.
  Args:
    img: A numpy array of uint8 with shape [image_size, image_size, 3].
    image_format: A string describing the image compression format.

  Returns:
    contents: The compressed image serialized to a string of bytes.
Get image encoded bytes from numpy array.
Get image encoded bytes from numpy array .
def encode_image(img, image_format):
  """Get image encoded bytes from numpy array.

     Note: use lossless PNG compression to test perfect reconstruction.
  Args:
    img: A numpy array of uint8 with shape [image_size, image_size, 3].
    image_format: A string describing the image compression format.

  Returns:
    contents: The compressed image serialized to a string of bytes.
  """
  img = Image.fromarray(img)
  buf = io.BytesIO()
  img.save(buf, image_format)
  buf.seek(0)
  img_bytes = buf.getvalue()
  buf.close()
  return img_bytes
def encode_image ( img , image_format ) : img = Image . fromarray ( img ) buf = io . BytesIO ( ) img . save ( buf , image_format ) buf . seek ( 0 ) img_bytes = buf . getvalue ( ) buf . close ( ) return img_bytes