public class ImageHelper extends Object
ImageHelper...| Constructor and Description |
|---|
ImageHelper() |
| Modifier and Type | Method and Description |
|---|---|
static Layer |
createLayer(ClassLoader cl,
String resource) |
static Layer |
createLayer(Item item)
Creates a layer of the given item.
|
static Layer |
createLayer(Node node,
String imageName,
String refName)
Creates a layer either by the node addressed by
imageName or
the referenced image addressed by the refName property. |
static Layer |
createLayer(Session session,
String path)
Creates a layer of the given item addressed by the path.
|
static Rectangle |
getCropRect(String rectCSV,
String path)
Parses a CSV string of the form "x1,y1,x2,y2" and returns the respective
rectangle.
|
static String |
getExtensionFromType(String type)
Returns the extension from the given image type.
|
static String |
getTypeFromExtension(String ext)
Returns the image type for the given extension.
|
static boolean |
handleIfModifiedSince(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
Node node)
Checks if the request contains a if-last-modified-since header and if the
node has a jcr:lastModified property.
|
static Color |
parseColor(String s)
Converts a
String to an integer and returns the
specified Color. |
static Color |
parseColor(String s,
int alpha)
Converts a
String to an integer and returns the
specified Color. |
static int |
parseFontStyle(String... styles)
Parses the font style from the given string(s).
|
static Layer |
resize(Layer layer,
Dimension d,
Dimension min,
Dimension max)
Resizes the given layer according to the given dimensions.
|
static Node |
saveLayer(Layer layer,
String type,
double quality,
Node parent,
String filename,
boolean replace)
Saves the layer as nt:file below the given node.
|
public static Rectangle getCropRect(String rectCSV, String path)
null is
returned. The method can deal with an aspect ratio that is appended by "/" (e.g.
"x1,y1,x2,y2/ratioX,ratioY".rectCSV - the rectangle coordinatespath - optional path for debuggingnullpublic static Layer createLayer(Node node, String imageName, String refName) throws RepositoryException, IOException
imageName or
the referenced image addressed by the refName property.node - the current nodeimageName - the name of the image noderefName - the name of the reference propertynullRepositoryException - if a repository error occursIOException - if a I/O error occurspublic static Layer createLayer(ClassLoader cl, String resource)
public static Layer createLayer(Session session, String path) throws RepositoryException, IOException
session - to use for retrieving the itempath - to the itemnullRepositoryException - if a repository error occursIOException - if a I/O error occurspublic static Layer createLayer(Item item) throws RepositoryException, IOException
item - the itemnullRepositoryException - if a repository error occursIOException - if a I/O error occurspublic static int parseFontStyle(String... styles)
| style string | return |
|---|---|
| bold | AbstractFont.BOLD |
| italic | AbstractFont.ITALIC |
| underline | AbstractFont.UNDERLINE |
| strikeout | AbstractFont.STRIKEOUT |
| all other | AbstractFont.PLAIN |
styles - the stylespublic static Layer resize(Layer layer, Dimension d, Dimension min, Dimension max)
null
is returned.
Examples:
| lW | lH | dW | dH | minW | maxW | minH | maxH | w | h | comment | | | | 400 | 200 | 0 | 0 | 0 | 0 | 400 | 200 | no resizing | | | | 400 | 200 | 0 | 200 | 0 | 0 | 200 | 100 | 200 max width applies | | 120 | 80 | 0 | 0 | 100 | 400 | 50 | 100 | 120 | 80 | within bounds | | 120 | 80 | 0 | 0 | 0 | 100 | 50 | 100 | 100 | 60 | 100 max width applies | | 400 | 100 | 300 | 0 | 0 | 0 | 0 | 0 | 300 | 75 | resize proportional | | 400 | 100 | 300 | 0 | 0 | 0 | 0 | 50 | 200 | 50 | max height applies |
layer - layer to resize.d - dimensionmin - minimal dimension constraintsmax - maximal dimension constraintsnull if untouched.public static Color parseColor(String s)
String to an integer and returns the
specified Color. This method handles string
formats that are used to represent octal and hexadecimal numbers.
If the string cannot be converted an transparent black is returned.s - a String that represents an RGBA color as a 32-bit integerColor object.Integer.decode(java.lang.String)public static Color parseColor(String s, int alpha)
String to an integer and returns the
specified Color. This method handles string
formats that are used to represent octal and hexadecimal numbers.
If the string cannot be converted an transparent black is returned.s - a String that represents an RGB color as a 24-bit integeralpha - override the alpha settingColor object.Integer.decode(java.lang.String)public static Node saveLayer(Layer layer, String type, double quality, Node parent, String filename, boolean replace) throws RepositoryException, IOException
layer - the layer to savetype - image type. eg "image/png"quality - image quality. eg 1.0parent - parent nodefilename - file namereplace - if true existing node are replaced rather than updated.RepositoryException - if a repository error occurrsIOException - if an I/O error occurrspublic static String getTypeFromExtension(String ext)
ext - the extensionnull.public static String getExtensionFromType(String type)
type - the mime typenull.public static boolean handleIfModifiedSince(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
Node node)
req - the requestresp - the responsenode - the current nodetrue if the response was sent"Copyright © 2010 - 2017 Adobe Systems Incorporated. All Rights Reserved"