Class VisionImageUtil

java.lang.Object
com.chatmotorapi.api.vision.VisionImageUtil

public class VisionImageUtil
extends Object
Utility class for handling image files and converting them to Base64 encoded strings.
  • Constructor Details

    • VisionImageUtil

      public VisionImageUtil()
  • Method Details

    • loadImageAsBase64

      public static String loadImageAsBase64​(File imageFile) throws IOException
      Loads an image from the given File and converts it to a Base64 encoded string.
      Parameters:
      imageFile - the image file to be loaded and encoded.
      Returns:
      a Base64 encoded string representing the image, prefixed with the appropriate data URI scheme.
      Throws:
      IOException - if an I/O error occurs reading from the file or a required system property is not set.
      FileNotFoundException - if imageFile in null or the file does not exist.
    • loadImageAsBase64

      public static String loadImageAsBase64​(String imagePath) throws IOException
      Loads an image from the given file path and converts it to a Base64 encoded string.
      Parameters:
      imagePath - the file path of the image to be loaded and encoded.
      Returns:
      a Base64 encoded string representing the image, prefixed with the appropriate data URI scheme.
      Throws:
      IOException - if an I/O error occurs reading from the file or a required system property is not set.
      FileNotFoundException - if imagePath in null or the corresponding file does not exist.