Package com.structurizr.util
Class ImageUtils
java.lang.Object
com.structurizr.util.ImageUtils
Some utility methods for dealing with images.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetContentType(File file) Gets the content type of the specified file representing an image.static StringgetImageAsBase64(File file) Gets the content of an image as a Base64 encoded string.static StringgetImageAsDataUri(File file) Gets the content of an image as a data URI; e.g.static booleanisSupportedDataUri(String uri) static voidvalidateImage(String url)
-
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
-