Top Fields Constructors Methods
com.vladsch.flexmark.util.misc

public Class ImageUtils

extends Object
Class Inheritance
Imports
javax.imageio.ImageIO, java.awt.*, java.awt.datatransfer.DataFlavor, .Transferable, .UnsupportedFlavorException, java.awt.geom.AffineTransform, .RoundRectangle2D, java.awt.image.*, java.io.*, java.net.URL, java.nio.charset.StandardCharsets, java.util.Base64, java.util.regex.Pattern

Field Summary

Modifier and TypeField and Description
private static final Pattern
public static Color

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static BufferedImage
addBorder(BufferedImage image, Color borderColor, int borderWidth, int cornerRadius)

public static BufferedImage
public static BufferedImage
public static String
public static String
public static BufferedImage
cropImage(BufferedImage image, int trimLeft, int trimRight, int trimTop, int trimBottom)

public static BufferedImage
drawHighlightOval(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, Color innerFillColor)

public static BufferedImage
drawHighlightRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, Color innerFillColor)

public static BufferedImage
drawOval(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, float[] dash, float dashPhase)

public static BufferedImage
drawRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius)

public static BufferedImage
drawRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, float[] dash, float dashPhase)

public static byte[]
public static Image
public static Image
public static boolean
public static boolean
public static BufferedImage

Returns:

Could be null if the image could not be read from the file (because of whatever strange reason).
loadImageFromContent
(byte[]
file
cachedImageBytes
,
String
image file path for error reporting
idPath
)

public static BufferedImage

Returns:

Could be null if the image could not be read from the file (because of whatever strange reason).
loadImageFromFile
(File
file
cachedImageFile
)

public static BufferedImage
public static BufferedImage

Returns:

image or null if failed to download.
loadImageFromURL
(String
url of the image
imageURL
,
boolean
true if errors are to print to console
logImageProcessing
)

Load image from URL.

public static BufferedImage
makeRoundedCorner(BufferedImage image, int cornerRadius, int borderWidth)

public static BufferedImage
punchOuterHighlightOval(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)

public static BufferedImage
punchOuterHighlightRectangle(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, int cornerRadius, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)

public static BufferedImage
public static void
save(BufferedImage image, File file, String format)

public static BufferedImage
scaleImage(BufferedImage sourceImage, int newWidth, int newHeight, int opType)

public static BufferedImage
public static Image
toTransparent(BufferedImage image, Color color, int tolerance)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BASE64_ENCODING_PATTERNback to summary
private static final Pattern BASE64_ENCODING_PATTERN
TRANSPARENTback to summary
public static Color TRANSPARENT

Constructor Detail

ImageUtilsback to summary
public ImageUtils()

Method Detail

addBorderback to summary
public static BufferedImage addBorder(BufferedImage image, Color borderColor, int borderWidth, int cornerRadius)
base64Decodeback to summary
public static BufferedImage base64Decode(File file)
base64Decodeback to summary
public static BufferedImage base64Decode(String encoded)
base64Encodeback to summary
public static String base64Encode(BufferedImage image)
base64Encodeback to summary
public static String base64Encode(File file)
cropImageback to summary
public static BufferedImage cropImage(BufferedImage image, int trimLeft, int trimRight, int trimTop, int trimBottom)
drawHighlightOvalback to summary
public static BufferedImage drawHighlightOval(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, Color innerFillColor)
drawHighlightRectangleback to summary
public static BufferedImage drawHighlightRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, Color innerFillColor)
drawOvalback to summary
public static BufferedImage drawOval(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, float[] dash, float dashPhase)
drawRectangleback to summary
public static BufferedImage drawRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius)
drawRectangleback to summary
public static BufferedImage drawRectangle(BufferedImage image, int x, int y, int w, int h, Color borderColor, int borderWidth, int cornerRadius, float[] dash, float dashPhase)
getImageBytesback to summary
public static byte[] getImageBytes(BufferedImage image)
getImageFromClipboardback to summary
public static Image getImageFromClipboard()
getImageFromTransferableback to summary
public static Image getImageFromTransferable(Transferable transferable)
isEncodedImageback to summary
public static boolean isEncodedImage(String encoded)
isPossiblyEncodedImageback to summary
public static boolean isPossiblyEncodedImage(String encoded)
loadImageFromContentback to summary
public static BufferedImage loadImageFromContent(byte[] cachedImageBytes, String idPath)
Parameters
cachedImageBytes:byte[]

file

idPath:String

image file path for error reporting

Returns:BufferedImage

Could be null if the image could not be read from the file (because of whatever strange reason).

loadImageFromFileback to summary
public static BufferedImage loadImageFromFile(File cachedImageFile)
Parameters
cachedImageFile:File

file

Returns:BufferedImage

Could be null if the image could not be read from the file (because of whatever strange reason).

loadImageFromURLback to summary
public static BufferedImage loadImageFromURL(String imageURL)
loadImageFromURLback to summary
public static BufferedImage loadImageFromURL(String imageURL, boolean logImageProcessing)

Load image from URL.

Note

Java7 JDK cannot load some images including GitHub emoji. Compiling this library with Java8 solves the problem.

Parameters
imageURL:String

url of the image

logImageProcessing:boolean

true if errors are to print to console

Returns:BufferedImage

image or null if failed to download.

makeRoundedCornerback to summary
public static BufferedImage makeRoundedCorner(BufferedImage image, int cornerRadius, int borderWidth)
punchOuterHighlightOvalback to summary
public static BufferedImage punchOuterHighlightOval(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)
punchOuterHighlightRectangleback to summary
public static BufferedImage punchOuterHighlightRectangle(BufferedImage image, BufferedImage outerImage, int x, int y, int w, int h, int borderWidth, int cornerRadius, Color outerFillColor, int outerBorderWidth, int outerCornerRadius, boolean applyToImage)
removeAlphaback to summary
public static BufferedImage removeAlpha(BufferedImage image)
saveback to summary
public static void save(BufferedImage image, File file, String format)
scaleImageback to summary
public static BufferedImage scaleImage(BufferedImage sourceImage, int newWidth, int newHeight, int opType)
toBufferedImageback to summary
public static BufferedImage toBufferedImage(Image src)
toTransparentback to summary
public static Image toTransparent(BufferedImage image, Color color, int tolerance)