Package com.xmlmind.w2x.docx.image
Class ImageConverterFactories
- java.lang.Object
-
- com.xmlmind.w2x.docx.image.ImageConverterFactories
-
public final class ImageConverterFactories extends Object
The registry of allimage converter factoriesused by W2X.Initially this registry contains only a factory based on
ImageIO. This factory is used to convert TIFF images to JPEG or PNG images. However for this conversion to work, you must use Java 9 to run W2X.This class is thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description static booleantraceIftrue, trace image conversions.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileconvertImage(File imgFile, String[] preferredExtensions)Convenience method: find a factory allowing to convert specified image file to SVG, PNG or JPEG, then use this factory to create an image converter and then use the converter to perform the file conversion.static ImageConverterFactoryget(String inExt, String outExt)Returns a factory allowing to convert specified input filename extension to specified output filename extension.static voidregister(ImageConverterFactory factory)Registers specified factory.static StringtoSpecString()
-
-
-
Method Detail
-
register
public static void register(ImageConverterFactory factory)
Registers specified factory.
-
toSpecString
public static String toSpecString()
-
get
public static ImageConverterFactory get(String inExt, String outExt)
Returns a factory allowing to convert specified input filename extension to specified output filename extension.Each registered factory is tested in turn, starting from the last registered ones.
- Parameters:
inExt- input filename extensionoutExt- output filename extension- Returns:
- a factory if found;
nullotherwise
-
convertImage
public static File convertImage(File imgFile, String[] preferredExtensions)
Convenience method: find a factory allowing to convert specified image file to SVG, PNG or JPEG, then use this factory to create an image converter and then use the converter to perform the file conversion.- Parameters:
imgFile- an image filepreferredExtensions- specifies preferred converted image extensions.It's an array containing 0 to 3 image file extensions: "
svg", "png" and "jpeg". The order of the extensions specifies the preferred converted image format.May be
nullin which case{"svg", "png", "jpeg"}is used.- Returns:
- the image file converted to SVG, JPEG or PNG or
null.nullis returned in any of the following cases:imgFileis already in GIF, PNG, JPEG or SVG format.- A suitable image converter is not found in the registry.
- The found image converter fails to perform the conversion.
-
-