com.flexive.shared.media
Class FxMediaEngine

java.lang.Object
  extended by com.flexive.shared.media.FxMediaEngine

public class FxMediaEngine
extends java.lang.Object

Media engine

Version:
$Rev: 704 $
Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Constructor Summary
FxMediaEngine()
           
 
Method Summary
static java.lang.String detectMimeType(byte[] header)
          Detect the mimetype of a file based on the first n bytes and the filename
static java.lang.String detectMimeType(byte[] header, java.lang.String fileName)
          Detect the mimetype of a file based on the first n bytes and the filename
static java.lang.String getImageMagickVersion()
          Get the ImageMagick version as String
static boolean hasImageMagickInstalled()
          Is ImageMagick installed?
static FxMetadata identify(java.lang.String mimeType, java.io.File file)
          Identify a file, returning metadata
static boolean isImageMagickIdentifySupported()
          We need at least version 6.3.x of ImageMagick to be able to parse identify output
static int[] scale(java.io.File original, java.io.File scaled, java.lang.String extension, int width, int height)
          Scale an image and return the dimensions (width and height) as int array
static void streamingManipulate(byte[] data, java.io.OutputStream out, BinaryDownloadCallback callback, java.lang.String mimeType, FxMediaSelector selector)
          Manipulate image raw data and stream them back
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FxMediaEngine

public FxMediaEngine()
Method Detail

hasImageMagickInstalled

public static boolean hasImageMagickInstalled()
Is ImageMagick installed?

Returns:
if ImageMagick is installed

getImageMagickVersion

public static java.lang.String getImageMagickVersion()
Get the ImageMagick version as String

Returns:
ImageMagick version as String

isImageMagickIdentifySupported

public static boolean isImageMagickIdentifySupported()
We need at least version 6.3.x of ImageMagick to be able to parse identify output

Returns:
can ImageMagick's identify be used?

identify

public static FxMetadata identify(java.lang.String mimeType,
                                  java.io.File file)
Identify a file, returning metadata

Parameters:
mimeType - if not null it will be used to call the correct identify routine
file - the file to identify
Returns:
metadata

scale

public static int[] scale(java.io.File original,
                          java.io.File scaled,
                          java.lang.String extension,
                          int width,
                          int height)
                   throws FxApplicationException
Scale an image and return the dimensions (width and height) as int array

Parameters:
original - original file
scaled - scaled file
extension - extension
width - desired width
height - desired height
Returns:
actual width ([0]) and height ([1]) of scaled image
Throws:
FxApplicationException - on errors

streamingManipulate

public static void streamingManipulate(byte[] data,
                                       java.io.OutputStream out,
                                       BinaryDownloadCallback callback,
                                       java.lang.String mimeType,
                                       FxMediaSelector selector)
                                throws FxApplicationException
Manipulate image raw data and stream them back

Parameters:
data - raw image data
out - stream
callback - optional callback to set mimetype and size
mimeType - mimetype
selector - operations to apply
Throws:
FxApplicationException - on errors

detectMimeType

public static java.lang.String detectMimeType(byte[] header)
Detect the mimetype of a file based on the first n bytes and the filename

Parameters:
header - first n bytes of the file to examine
Returns:
detected mimetype

detectMimeType

public static java.lang.String detectMimeType(byte[] header,
                                              java.lang.String fileName)
Detect the mimetype of a file based on the first n bytes and the filename

Parameters:
header - first n bytes of the file to examine
fileName - filename
Returns:
detected mimetype