Class ImageTransformer

  • All Implemented Interfaces:
    IXMLConfigurable, IImporterHandler, IDocumentTransformer

    public class ImageTransformer
    extends AbstractDocumentTransformer

    Transforms an image using common image operations.

    This class should only be used as a pre-parsing handler, on image files. It may also be appropriate to disable parsing of those images if you want to keep the transformed version intact. This can be done with GenericDocumentParserFactory.

    Content-types

    By default, this filter is restricted to (applies only to) documents matching the restrictions returned by CommonRestrictions.imageIOStandardContentTypes(String). You can specify your own content types if you know they represent a supported image.

    Image dimension format

    For a list of supported image dimension formats, refer to DimensionConverter.

    XML configuration usage:

    
    <handler
        class="com.norconex.importer.handler.transformer.impl.ImageTransformer"
        targetFormat="(jpg, png, gif, bmp, wbmp, or other supported format)">
      <!-- multiple "restrictTo" tags allowed (only one needs to match) -->
      <restrictTo>
        <fieldMatcher>(field-matching expression)</fieldMatcher>
        <valueMatcher>(value-matching expression)</valueMatcher>
      </restrictTo>
      <scale
          stretch="[false|true]"
          factor="(decimal value ratio factor, default is 1)"
          dimension="(target dimension, in pixels, format: [width]x[height])"/>
      <rotate
          degrees="(-360 to 360)"/>
      <crop
          x="(top-left x-axis, default 0)"
          y="(top-left y-axis, default 0)"
          dimension="(crop dimension, in pixels, format: [width]x[height])"/>
    </handler>

    XML usage example:

    
    <handler
        class="ImageTransformer"
        targetFormat="png">
      <scale
          dimension="400x250"/>
    </handler>

    Usage example:

    The above example converts images to PNG while scaling it to a maximum dimension of 400 pixels wide and 250 pixel high.

    Since:
    3.0.0
    Author:
    Pascal Essiembre
    See Also:
    ExternalHandler