Package com.structurizr.util
Class ImageUtils
java.lang.Object
com.structurizr.util.ImageUtils
public class ImageUtils
extends java.lang.Object
Some utility methods for dealing with images.
-
Constructor Summary
Constructors Constructor Description ImageUtils() -
Method Summary
Modifier and Type Method Description static java.lang.StringgetContentType(java.io.File file)Gets the content type of the specified file representing an image.static java.lang.StringgetImageAsBase64(java.io.File file)Gets the content of an image as a Base64 encoded string.static java.lang.StringgetImageAsDataUri(java.io.File file)Gets the content of an image as a data URI; e.g.
-
Constructor Details
-
ImageUtils
public ImageUtils()
-
-
Method Details
-
getContentType
public static java.lang.String getContentType(@Nonnull java.io.File file) throws java.io.IOExceptionGets 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:
java.io.IOException- if there is an error reading the file
-
getImageAsBase64
public static java.lang.String getImageAsBase64(@Nonnull java.io.File file) throws java.io.IOExceptionGets 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:
java.io.IOException- if there is an error reading the file
-
getImageAsDataUri
public static java.lang.String getImageAsDataUri(java.io.File file) throws java.io.IOExceptionGets 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:
java.io.IOException- if there is an error reading the file
-