Package com.chatmotorapi.api.vision
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 Summary
Constructors Constructor Description VisionImageUtil() -
Method Summary
Modifier and Type Method Description static StringloadImageAsBase64(File imageFile)Loads an image from the givenFileand converts it to a Base64 encoded string.static StringloadImageAsBase64(String imagePath)Loads an image from the given file path and converts it to a Base64 encoded string.
-
Constructor Details
-
VisionImageUtil
public VisionImageUtil()
-
-
Method Details
-
loadImageAsBase64
Loads an image from the givenFileand 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
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.
-