Package com.structurizr.util
Class ImageUtils
java.lang.Object
com.structurizr.util.ImageUtils
Some utility methods for dealing with images.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getContentType
(File file) Gets the content type of the specified file representing an image.static String
getContentType
(String url) Gets the content type of the specified URL representing an image.static String
getContentTypeFromDataUri
(String dataUri) Gets the content type of the specified data URI 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)
-
Field Details
-
DATA_URI_PREFIX
- See Also:
-
DATA_URI_IMAGE_PNG
- See Also:
-
DATA_URI_IMAGE_JPG
- See Also:
-
DATA_URI_IMAGE_SVG
- See Also:
-
CONTENT_TYPE_IMAGE_PNG
- See Also:
-
CONTENT_TYPE_IMAGE_JPG
- See Also:
-
CONTENT_TYPE_IMAGE_SVG
- See Also:
-
-
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
-
getContentType
Gets the content type of the specified URL representing an image.- Parameters:
url
- a URL pointing to an image- Returns:
- a content type (e.g. "image/png")
- Throws:
IOException
- if there is an error reading the file
-
getContentTypeFromDataUri
Gets the content type of the specified data URI representing an image.- Parameters:
dataUri
- a data URI representing an image- Returns:
- a content type (e.g. "image/png")
-
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
-