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 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 Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static boolean` | `trace` | If `true`, trace image conversions.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `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.
    `static ImageConverterFactory` | `get​(String inExt, String outExt)` | Returns a factory allowing to convert specified input filename extension to specified output filename extension.
    `static void` | `register​(ImageConverterFactory factory)` | Registers specified factory.
    `static String` | `toSpecString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### trace

          public static final boolean trace

      If `true`, trace image conversions.

  - ### 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 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.