de.vc.jfo.tools

## Class ImageTranscoder

- java.lang.Object
- - de.vc.jfo.tools.ImageTranscoder

- Direct Known Subclasses:
    InternalImageTranscoder, NativeCmdImageTranscode

      public abstract class ImageTranscoder
      extends java.lang.Object

  An image transcoder converts images into other formats.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canTranscodeFile(java.lang.String file)` Checks if this image transcoder can convert a `file`.
    `boolean` | `canTranscodeFormat(java.lang.String format)` Checks if this image transcode supports an input `format`
    `protected java.awt.Dimension` | `checkImageSize(java.awt.Dimension d)`
    `protected abstract void` | `doTranscode(java.io.InputStream input, java.io.OutputStream output, ImageMetaData descriptor)` Do transcode an image from an input stream to an output stream.
    `protected abstract void` | `doTranscode(java.lang.String inputFile, java.lang.String outputFile, ImageMetaData descriptor)` Do transcode an image from an input file to an output file.
    `abstract java.lang.String[]` | `getInputFormats()` Gets the input format of images that are accepted by this trancoder.
    `java.awt.Dimension` | `getMaximumSize()` Gets the maximum size of produced bitmap images.
    `abstract java.lang.String` | `getOutputFormat()` Gets the output format of the produced image.
    `protected static java.lang.String` | `getTypeOfFile(java.lang.String file)` Gets the type (extension) of a file.
    `boolean` | `isReady()` Checks if this transcode is ready to run.
    `void` | `setMaximumSize(java.awt.Dimension maximumSize)` Sets the maximum size of produced bitmap image.
    `void` | `transcodeBytes(java.io.InputStream input, java.io.OutputStream output, ImageMetaData descriptor)` Transcodes an image from an InputStream to an OutputStream.
    `java.lang.String` | `transcodeFile(java.lang.String inputFile, boolean skipIfExists, ImageMetaData descriptor)` Transcodes an image.
    `void` | `transcodeFile(java.lang.String inputFile, java.lang.String outputFile, boolean skipIfExists, ImageMetaData descriptor)` Transcodes an image from an inputFile to an outputFile.

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

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

- - ### Method Detail

    - #### getOutputFormat

          public abstract java.lang.String getOutputFormat()

      Gets the output format of the produced image. The format must be a subtype of image, e.g. png or bmp.
      Returns:
        Output format.

    - #### getInputFormats

          public abstract java.lang.String[] getInputFormats()

      Gets the input format of images that are accepted by this trancoder. The format must be a MIME subtype of image, e.g. png or bmp.
      Returns:
        Input format.

    - #### transcodeFile

          public java.lang.String transcodeFile(java.lang.String inputFile,
                                       boolean skipIfExists,
                                       ImageMetaData descriptor)

      Transcodes an image.
      Parameters:
        `inputFile` - Image file.
        `skipIfExists` - boolean Skip image if output file already exists.
        `descriptor` - Image descriptor.
      Returns:
        Generated output file.

    - #### transcodeFile

          public void transcodeFile(java.lang.String inputFile,
                           java.lang.String outputFile,
                           boolean skipIfExists,
                           ImageMetaData descriptor)

      Transcodes an image from an inputFile to an outputFile.
      Parameters:
        `inputFile` - Input file.
        `outputFile` - Output file
        `skipIfExists` - Skip transcoding if outputfile already exsist.
        `descriptor` - Descriptor for image.

    - #### transcodeBytes

          public void transcodeBytes(java.io.InputStream input,
                            java.io.OutputStream output,
                            ImageMetaData descriptor)

      Transcodes an image from an InputStream to an OutputStream.
      Parameters:
        `input` - Input stream.
        `output` - Output stream.
        `descriptor` - Descriptor for image.

    - #### canTranscodeFile

          public boolean canTranscodeFile(java.lang.String file)

      Checks if this image transcoder can convert a `file`.
      Parameters:
        `file` - File.
      Returns:
        `true` if this transcoder can convert `file`.

    - #### canTranscodeFormat

          public boolean canTranscodeFormat(java.lang.String format)

      Checks if this image transcode supports an input `format`
      Parameters:
        `format` - Format.
      Returns:
        `true` if this transcoder the input `format`.

    - #### isReady

          public boolean isReady()

      Checks if this transcode is ready to run. Normally always true is returned.
      Returns:
        `true`

    - #### setMaximumSize

          public void setMaximumSize(java.awt.Dimension maximumSize)

      Sets the maximum size of produced bitmap image. Some WMF or EMF images have a very big dimension that can lead to memory problems. Set the maximum size to scale images to a lower dimension. The default maximum size is 640 x 640 pixels.
      Parameters:
        `maximumSize` - Maximum size.

    - #### getMaximumSize

          public java.awt.Dimension getMaximumSize()

      Gets the maximum size of produced bitmap images.
      Returns:
        Dimension (never null)

    - #### doTranscode

          protected abstract void doTranscode(java.lang.String inputFile,
                         java.lang.String outputFile,
                         ImageMetaData descriptor)

      Do transcode an image from an input file to an output file.
      Parameters:
        `inputFile` - Input file.
        `outputFile` - Output file.
        `descriptor` - ImageDescriptor

    - #### doTranscode

          protected abstract void doTranscode(java.io.InputStream input,
                         java.io.OutputStream output,
                         ImageMetaData descriptor)

      Do transcode an image from an input stream to an output stream. You don't have to close the streams.
      Parameters:
        `input` - InputStream
        `output` - OutputStream
        `descriptor` - ImageDescriptor

    - #### getTypeOfFile

          protected static java.lang.String getTypeOfFile(java.lang.String file)

      Gets the type (extension) of a file.
      Parameters:
        `file` - Filename (e.g. power.png)
      Returns:
        Type/extension of file (e.g. png) or null if it is impossible to determinate the type.

    - #### checkImageSize

          protected java.awt.Dimension checkImageSize(java.awt.Dimension d)

© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.