Class ImageConverterFactories


  • public final class ImageConverterFactories
    extends Object
    The registry of all image converter factories used 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 Detail

      • trace

        public static final boolean trace
        If true, trace image conversions.
    • Method Detail

      • 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 extension
        outExt - output filename extension
        Returns:
        a factory if found; null otherwise
      • 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 file
        preferredExtensions - 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 null in which case {"svg", "png", "jpeg"} is used.

        Returns:
        the image file converted to SVG, JPEG or PNG or null.

        null is returned in any of the following cases:

        • imgFile is 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.