Package com.structurizr.util
Class ImageUtils
java.lang.Object
com.structurizr.util.ImageUtils
Some utility methods for dealing with images.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getContentType
(File file) Gets the content type of the specified file representing an image.static String
getImageAsBase64
(File file) Gets the content of an image as a Base64 encoded string.static String
getImageAsDataUri
(File file) Gets the content of an image as a data URI; e.g.static boolean
isSupportedDataUri
(String uri) static void
validateImage
(String imageDescriptor)
-
Constructor Details
-
ImageUtils
public ImageUtils()
-
-
Method Details
-
getContentType
Gets the content type of the specified file representing an image.- Parameters:
file
- a File pointing to an image- Returns:
- a content type (e.g. "image/png")
- Throws:
IOException
- if there is an error reading the file
-
getImageAsBase64
Gets the content of an image as a Base64 encoded string.- Parameters:
file
- a File pointing to an image- Returns:
- a Base64 encoded version of that image
- Throws:
IOException
- if there is an error reading the file
-
getImageAsDataUri
Gets the content of an image as a data URI; e.g. "data:image/png;base64,iVBORw0KGgoAA..."- Parameters:
file
- a File pointing to an image- Returns:
- a data URI
- Throws:
IOException
- if there is an error reading the file
-
validateImage
-
isSupportedDataUri
-