org.mmbase.util.images
Class Imaging

java.lang.Object
  extended by org.mmbase.util.images.Imaging

public abstract class Imaging
extends Object

Utilities related to Images.

Author:
Michiel Meeuwissen

Nested Class Summary
static class Imaging.CKey
          Structure with node-number and template.
 
Field Summary
static String FIELD_CKEY
           
static String FIELD_HANDLE
           
static Pattern GEOMETRY
           
 
Constructor Summary
Imaging()
           
 
Method Summary
static String getAlias(String a)
          MMBase has some abreviations to convert commands, like 's' for 'geometry'.
static String getMimeTypeByExtension(String ext)
          Returns the mimetype using ServletContext.getServletContext which returns the servlet context
static String getMimeTypeByFileName(String fileName)
           
static Imaging.CKey parseCKey(String ckey)
          Parses a ckey String into a CKey structure.
static List<String> parseTemplate(String template)
          Parses the 'image conversion template' to a List.
static Dimension predictDimension(Dimension originalSize, List<String> params)
          Predict the size of a image after converting it with the given parameters.
static int predictFileSize(Dimension originalDimension, int originalFileSize, Dimension predictedDimension)
          Tries to predict the new file-size after conversion.
protected static void removeSurroundingQuotes(StringBuilder buf)
          Just a utitility function, used by the function above.
static String unparseTemplate(List<String> params)
          Only used in legacy-support and perhaps debug code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIELD_HANDLE

public static final String FIELD_HANDLE
See Also:
Constant Field Values

FIELD_CKEY

public static final String FIELD_CKEY
See Also:
Constant Field Values

GEOMETRY

public static final Pattern GEOMETRY
Constructor Detail

Imaging

public Imaging()
Method Detail

getMimeTypeByExtension

public static String getMimeTypeByExtension(String ext)
Returns the mimetype using ServletContext.getServletContext which returns the servlet context

Parameters:
ext - A String containing the extension.
Returns:
The mimetype.

getMimeTypeByFileName

public static String getMimeTypeByFileName(String fileName)

getAlias

public static String getAlias(String a)
MMBase has some abreviations to convert commands, like 's' for 'geometry'. These are treated here.

Parameters:
a - alias
Returns:
actual convert parameter name for alias.

parseTemplate

public static List<String> parseTemplate(String template)
Parses the 'image conversion template' to a List. I.e. it break it up in substrings, with '+' delimiter. However a + char does not count if it is somewhere between brackets (). Brackets nor +-chars count if they are in quotes (single or double)

Since:
MMBase-1.7

removeSurroundingQuotes

protected static void removeSurroundingQuotes(StringBuilder buf)
Just a utitility function, used by the function above.

Since:
MMBase-1.7

unparseTemplate

public static String unparseTemplate(List<String> params)
Only used in legacy-support and perhaps debug code.


predictDimension

public static Dimension predictDimension(Dimension originalSize,
                                         List<String> params)
Predict the size of a image after converting it with the given parameters. This will not actually trigger a conversion, but only calculate the dimension of the result, so only involves some basic arithmetic and string-parsing. Most transformations which alter the dimension of an image are supported: geometry, border, rotate, part. Probably because of different rounding strategies, there is sometimes a difference of one or two pixels beteen the prediction and/or the result of ImageMagick and/or JAI.

Returns:
A reasonable prediction of the new dimension or Dimension.UNDETERMINED if that really is not possible

predictFileSize

public static int predictFileSize(Dimension originalDimension,
                                  int originalFileSize,
                                  Dimension predictedDimension)
Tries to predict the new file-size after conversion. The result (in the current implementation) is very unreliable, because it assumes that the file-size is proportional to the area.


parseCKey

public static Imaging.CKey parseCKey(String ckey)
Parses a ckey String into a CKey structure.



MMBase 2.0-SNAPSHOT - null