public final class ImageToolkits extends Object
This class is thread-safe. Moreover the convenience methods below do not assume that registered image toolkits are thread-safe.
Modifier and Type | Method and Description |
---|---|
static boolean |
convertImage(File inFile,
File outFile,
String[] parameters,
Console console)
Convenience method: checks all registered toolkits to convert specified
files.
|
static Image |
createImage(byte[] data,
URL baseURL)
Convenience method: checks all registered toolkits to create an image
representing specified data.
|
static Image |
createImage(byte[] data,
URL baseURL,
double width,
SizeType widthType,
double height,
SizeType heightType,
boolean preserveAspectRatio,
boolean smooth)
Convenience method: checks all registered toolkits to create an image
representing specified data.
|
static Image |
createImage(Element element)
Convenience method: checks all registered toolkits to create an image
representing specified tree of XML nodes.
|
static Image |
createImage(Element element,
double width,
SizeType widthType,
double height,
SizeType heightType,
boolean preserveAspectRatio,
boolean smooth)
Convenience method: checks all registered toolkits to create an image
representing specified tree of XML nodes.
|
static Image |
createImage(URL url)
Convenience method: checks all registered toolkits to create an image
representing specified URL.
|
static Image |
createImage(URL url,
double width,
SizeType widthType,
double height,
SizeType heightType,
boolean preserveAspectRatio,
boolean smooth)
Convenience method: checks all registered toolkits to create an image
representing specified URL.
|
static String[] |
detectImageFormat(byte[] data)
Returns a list of filename extensions customarily used for specified
image data (example:
{"jpeg", "jpg"} ). |
static ImageToolkit[] |
getAll()
Returns all registered toolkits.
|
static ImageToolkit |
getBuiltin()
Returns built-in
JavaImageToolkit . |
static int[] |
getImageSize(byte[] data,
URL baseURL)
Convenience method: checks all registered toolkits to determine
the intrinsic dimension of the image contained in specified data.
|
static int[] |
getImageSize(Element element)
Convenience method: checks all registered toolkits to determine
the intrinsic dimension of the image contained in specified tree
of XML nodes.
|
static int[] |
getImageSize(URL url)
Convenience method: checks all registered toolkits to determine
the intrinsic dimension of the image located at specified URL.
|
static ImageToolkit |
getToolkitForExtension(String extension)
Returns the toolkit capable of displaying image files having specified
extension.
|
static void |
register(ImageToolkit toolkit)
Registers specified toolkit.
|
static void |
unregisterAllExternal()
Discards all
ExternalImageToolkits . |
public static void register(ImageToolkit toolkit)
If toolkit has already been registered
(checks ImageToolkit.getName()
), registered toolkit is replaced
by specified instance.
Toolkits are sorted by their names by the built-in image toolkit (based on javax.imageio.ImageIO) always comes first and external image toolkits (based on external commands) always come last.
public static ImageToolkit getBuiltin()
JavaImageToolkit
.public static ImageToolkit[] getAll()
Note that order of toolkits may be important because each toolkit is tested in turn to see if it can handle the image format of interest.
For performance reasons, ExternalImageToolkits
, which invoke external command-line utilities,
are always found at the end of this list.
public static void unregisterAllExternal()
ExternalImageToolkits
.public static String[] detectImageFormat(byte[] data)
{"jpeg", "jpg"}
). Returns
null
if specified image data do not start with known magic
numbers.
Similar to ImageToolkitUtil.match(byte[], byte[])
except that the
magic numbers declared by ExternalImageToolkits
are taken into account.
public static Image createImage(URL url) throws Exception
null
if a suitable
toolkit is not found.Exception
public static Image createImage(URL url, double width, SizeType widthType, double height, SizeType heightType, boolean preserveAspectRatio, boolean smooth) throws Exception
null
if a suitable
toolkit is not found.
Arguments are interpreted like described for ImageRenderer.createImage(URL, double, SizeType, double, SizeType,
boolean, boolean)
, except that "data:" URLs are supported
and URLs having a fragment are supported.
Exception
public static Image createImage(byte[] data, URL baseURL) throws Exception
null
if a suitable
toolkit is not found.Exception
public static Image createImage(byte[] data, URL baseURL, double width, SizeType widthType, double height, SizeType heightType, boolean preserveAspectRatio, boolean smooth) throws Exception
null
if a suitable
toolkit is not found.
Arguments are interpreted like described for ImageRenderer.createImage(byte[], URL, double, SizeType,
double, SizeType, boolean, boolean)
.
Exception
public static Image createImage(Element element) throws Exception
null
if
a suitable toolkit is not found.Exception
public static Image createImage(Element element, double width, SizeType widthType, double height, SizeType heightType, boolean preserveAspectRatio, boolean smooth) throws Exception
null
if
a suitable toolkit is not found.
Arguments are interpreted like described for ImageRenderer.createImage(Element, double, SizeType, double, SizeType,
boolean, boolean)
.
Exception
public static int[] getImageSize(URL url) throws Exception
null
if a suitable toolkit is not found.
"data:" URLs are supported and URLs having a fragment are supported.
Exception
public static int[] getImageSize(byte[] data, URL baseURL) throws Exception
null
if a suitable toolkit is not found.Exception
public static int[] getImageSize(Element element) throws Exception
null
if a suitable toolkit is
not found.Exception
public static boolean convertImage(File inFile, File outFile, String[] parameters, Console console) throws Exception
false
if a suitable toolkit is not found.
Arguments are interpreted like described for ImageConverter.convertImage(java.io.File, java.io.File, java.lang.String[], com.xmlmind.util.Console)
.
Exception
public static ImageToolkit getToolkitForExtension(String extension)
null
if this toolkit is not found.extension
- the filename extension. Case insentive.
Must not start with a dot ('.').