docs: def data_preprocess(data, size=None, min_axis=None, batch=False):
      """
      Takes data and prepares it for sending to the api including
      resizing and image data/structure standardizing.
      """
      if batch:
          return [data_preprocess(el, size=size, min_axis=min_axis, batch=False) for el in data]
  
      if isinstance(data, string_types):
          if file_exists(data):
              # probably a path to an image
              preprocessed = Image.open(data)
          else:
              # base 64 encoded image data, a url, or raw content
              # send raw data to the server and let the server infer type
              b64_or_url = re.sub('^data:image/.+;base64,', '', data)
              return b64_or_url
  
      elif isinstance(data, Image.Image):
          # data is image from PIL
          preprocessed = data
  
      elif type(data).__name__ == "ndarray":
          # data is likely image from numpy/scipy
          if "float" in str(data.dtype) and data.min() >= 0 and data.max() <= 1:
              data *= 255.
          try:
              preprocessed = Image.fromarray(data.astype("uint8"))
          except TypeError:
              raise IndicoError(
                  "Please ensure the numpy array is in a format by PIL. "
                  "Values must be between 0 and 1 or between 0 and 255 in greyscale, rgb, or rgba format."
              )
  
      else:
          # at this point we are unsure of the type -- it could be malformatted text or image data.
          raise IndicoError(
              "Invalid input datatype: `{}`. "
              "Ensure input data is one of the following types: "
              "`str`, `unicode`, `PIL.Image`, `np.ndarray`.".format(
                  data.__class__.__name__
              )
          )
  
      #
      if size or min_axis:
          preprocessed = resize_image(preprocessed, size, min_axis)
  
      # standardize on b64 encoding for sending image data over the wire
      temp_output = BytesIO()
      preprocessed.save(temp_output, format='PNG')
      temp_output.seek(0)
      output_s = temp_output.read()
      return base64.b64encode(output_s).decode('utf-8') if PY3 else base64.b64encode(output_s)