org.mmbase.util.images
Class ImageMagickImageConverter

java.lang.Object
  extended by org.mmbase.util.images.AbstractImageConverter
      extended by org.mmbase.util.images.ImageMagickImageConverter
All Implemented Interfaces:
ImageConverter

public class ImageMagickImageConverter
extends AbstractImageConverter
implements ImageConverter

Converts images using ImageMagick.

Version:
$Id: ImageMagickImageConverter.java 40916 2010-02-08 17:51:01Z michiel $
Author:
Rico Jansen, Michiel Meeuwissen, Nico Klasens, Jaco de Groot

Nested Class Summary
static class ImageMagickImageConverter.Copier
           
 
Field Summary
protected  Set<String> excludeFormats
           
protected  String host
           
(package private) static Pattern IM_VERSION_PATTERN
           
protected  int method
           
static int METHOD_CONNECTOR
           
static int METHOD_LAUNCHER
           
protected  int port
           
(package private)  Set<String> validFormats
           
 
Constructor Summary
ImageMagickImageConverter()
           
 
Method Summary
protected  String color(String c)
          Translates MMBase color format (without #) to an convert color format (with or without);
protected  long connectorConvertImage(List<String> cmd, String[] env, InputStream originalStream, OutputStream imageStream, OutputStream errorStream)
           
 long convertImage(InputStream input, String sourceFormat, OutputStream out, List<String> commands)
          This functions converts an image by the given parameters
 void init(Map<String,String> params)
          This function initializes this class
protected  boolean isAnimated(InputStream inp)
           
 boolean isMinimumVersion(int major, int minor, int patch)
          Test whether the current version of ImageMagick is at least a certain version.
protected  long launcherConvertImage(List<String> cmd, String[] env, InputStream originalStream, OutputStream imageStream, OutputStream errorStream)
           
static void main(String[] args)
           
 String toString()
           
 
Methods inherited from class org.mmbase.util.images.AbstractImageConverter
convertImage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.util.images.ImageConverter
convertImage
 

Field Detail

IM_VERSION_PATTERN

static final Pattern IM_VERSION_PATTERN

METHOD_LAUNCHER

public static final int METHOD_LAUNCHER
See Also:
Constant Field Values

METHOD_CONNECTOR

public static final int METHOD_CONNECTOR
See Also:
Constant Field Values

method

protected int method

host

protected String host

port

protected int port

excludeFormats

protected Set<String> excludeFormats

validFormats

final Set<String> validFormats
Constructor Detail

ImageMagickImageConverter

public ImageMagickImageConverter()
Method Detail

init

public void init(Map<String,String> params)
This function initializes this class

Specified by:
init in interface ImageConverter
Overrides:
init in class AbstractImageConverter
Parameters:
params - a Map of Strings containing information, this should contain the key's ImageConvert.ConverterRoot and ImageConvert.ConverterCommand specifying the converter root, and it can also contain ImageConvert.DefaultImageFormat which can also be 'asis'.
See Also:
ImageConverter.init(java.util.Map)

isMinimumVersion

public boolean isMinimumVersion(int major,
                                int minor,
                                int patch)
Test whether the current version of ImageMagick is at least a certain version.

Parameters:
major - minimum major version number
minor - minimum minor version number within the major version
patch - minimum patch version number within the minor version
Returns:
true if the version is equal to or later than major.minor.patch
Since:
MMBase-1.9.2

convertImage

public long convertImage(InputStream input,
                         String sourceFormat,
                         OutputStream out,
                         List<String> commands)
                  throws IOException
This functions converts an image by the given parameters

Specified by:
convertImage in interface ImageConverter
Overrides:
convertImage in class AbstractImageConverter
Parameters:
input - an array of byte which represents the original image
sourceFormat - original image format
commands - a List of Strings containing commands which are operations on the image which will be returned. ImageConvert.converterRoot and ImageConvert.converterCommand specifying the converter root....
out - stream of bytes containing the new converted image.
Returns:
The number of bytes produces
Throws:
IOException - When an error occurs when converting the image
See Also:
ImageConverter.convertImage(java.io.InputStream, java.lang.String, java.io.OutputStream, java.util.List)

isAnimated

protected boolean isAnimated(InputStream inp)

color

protected String color(String c)
Translates MMBase color format (without #) to an convert color format (with or without);

Parameters:
c - color to convert
Returns:
converted color

launcherConvertImage

protected long launcherConvertImage(List<String> cmd,
                                    String[] env,
                                    InputStream originalStream,
                                    OutputStream imageStream,
                                    OutputStream errorStream)
                             throws ProcessException
Throws:
ProcessException

connectorConvertImage

protected long connectorConvertImage(List<String> cmd,
                                     String[] env,
                                     InputStream originalStream,
                                     OutputStream imageStream,
                                     OutputStream errorStream)
                              throws UnknownHostException,
                                     IOException,
                                     InterruptedException
Throws:
UnknownHostException
IOException
InterruptedException

toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


MMBase 2.0-SNAPSHOT - null