org.mmbase.util.images
Class ImageMagickImageConverter
java.lang.Object
org.mmbase.util.images.AbstractImageConverter
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
|
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()
|
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
ImageMagickImageConverter
public ImageMagickImageConverter()
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 numberminor - minimum minor version number within the major versionpatch - 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 imagesourceFormat - original image formatcommands - 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