|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.openutils.mgnlmedia.media.utils.ImageUtils
public final class ImageUtils
Main utility class that works with images and media nodes
| Field Summary | |
|---|---|
static String |
RESOLUTION_PROPERTY
Nodedata name where resolution is saved |
| Method Summary | |
|---|---|
static BufferedImage |
addRoundedCorners(BufferedImage original,
Color backgroundColor,
int radius)
Create rounded corners on image |
static boolean |
checkOrCreateResolution(info.magnolia.cms.core.Content media,
String resolutionTarget)
Check if the resolution for a media is already present. |
static boolean |
checkOrCreateResolution(info.magnolia.cms.core.Content media,
String resolutionTarget,
String nodeDataName)
Check if the resolution for a media is already present. |
static BufferedImage |
createBufferedImage(info.magnolia.cms.core.NodeData image)
Create a buffered image from the binary data stored in nodedata |
static BufferedImage |
cropImage(BufferedImage original,
int left,
int top,
int width,
int height)
Crop an image from left, top for width, height |
static String |
getExtension(info.magnolia.cms.core.Content media,
String resolution)
Get file extension for a resolution stored in a media node |
static BufferedImage |
getImageForResolution(BufferedImage original,
String resolution,
Map<String,String> params)
Get image for a resolution |
static String |
getResolutionPath(String resolution)
Get resolution nodedata name for a given resolution string |
protected static info.magnolia.cms.core.Content |
getResolutionsNode(info.magnolia.cms.core.Content media)
Returns the "resolutions" node, checking for existence |
static BufferedImage |
getScaledInstance(BufferedImage img,
int targetWidth,
int targetHeight,
Object hint,
boolean higherQuality)
Convenience method that returns a scaled instance of the provided BufferedImage. |
static long |
getStream(BufferedImage image,
String extension,
float quality,
boolean forceProgressive,
OutputStream outputstream)
Get an inputstream for an image and the target file extension |
static Point |
parseForSize(String res)
Parse resolution string for required sizesuper.read(b); |
static BufferedImage |
resizeImage(BufferedImage original,
int x,
int y)
Resize an image to x,y |
static BufferedImage |
resizeImage(BufferedImage original,
int x,
int y,
int canvasX,
int canvasY,
Color background)
Resize an image to x,y |
static void |
saveResolution(BufferedImage image,
info.magnolia.cms.core.Content saveTo,
String extension,
float quality,
boolean forceProgressive)
Save a resolution for an image to a node (in resolutions/res-[width]x[height]/data.jpg) |
static void |
saveResolution(BufferedImage image,
info.magnolia.cms.core.Content saveTo,
String name,
String extension,
float quality,
boolean forceProgressive)
Save a resolution for an image to a node (in resolutions/[name]/data.jpg) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String RESOLUTION_PROPERTY
| Method Detail |
|---|
public static BufferedImage resizeImage(BufferedImage original,
int x,
int y)
original - original imagex - new widthy - new height
public static BufferedImage resizeImage(BufferedImage original,
int x,
int y,
int canvasX,
int canvasY,
Color background)
original - original imagex - new widthy - new heightcanvasX - canvas widthcanvasY - canvas heightbackground - background color
public static BufferedImage getScaledInstance(BufferedImage img,
int targetWidth,
int targetHeight,
Object hint,
boolean higherQuality)
BufferedImage.
img - the original image to be scaledtargetWidth - the desired width of the scaled instance, in pixelstargetHeight - the desired height of the scaled instance, in pixelshint - one of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION (e.g.
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, RenderingHints.VALUE_INTERPOLATION_BILINEAR,
RenderingHints.VALUE_INTERPOLATION_BICUBIC)higherQuality - if true, this method will use a multi-step scaling technique that provides higher quality
than the usual one-step technique (only useful in downscaling cases, where targetWidth or
targetHeight is smaller than the original dimensions, and generally only when the BILINEAR hint
is specified)
BufferedImage
public static BufferedImage cropImage(BufferedImage original,
int left,
int top,
int width,
int height)
original - original imageleft - start crop point lefttop - start crop point topwidth - crop widthheight - crop height
public static BufferedImage addRoundedCorners(BufferedImage original,
Color backgroundColor,
int radius)
original - original imagebackgroundColor - optional background colorradius - corners radius
public static void saveResolution(BufferedImage image,
info.magnolia.cms.core.Content saveTo,
String extension,
float quality,
boolean forceProgressive)
throws javax.jcr.RepositoryException,
IOException
image - image to savesaveTo - node to save toextension - extensionquality - image qualityforceProgressive - true to force progressive mode
javax.jcr.RepositoryException - exception in jcr operations
IOException - exception converting image to jpg
public static void saveResolution(BufferedImage image,
info.magnolia.cms.core.Content saveTo,
String name,
String extension,
float quality,
boolean forceProgressive)
throws javax.jcr.RepositoryException,
IOException
image - image to savesaveTo - node to save toname - name for this resolutionextension - extensionquality - image qualityforceProgressive - true to force progressive mode
javax.jcr.RepositoryException - exception in jcr operations
IOException - exception converting image to jpgpublic static String getResolutionPath(String resolution)
resolution - resolution string
public static long getStream(BufferedImage image,
String extension,
float quality,
boolean forceProgressive,
OutputStream outputstream)
throws IOException
image - image to get the inputstream fromextension - target file extensionquality - image qualityforceProgressive - true if image has to be saved as progressive mode
IOException
public static boolean checkOrCreateResolution(info.magnolia.cms.core.Content media,
String resolutionTarget)
media - media to check the resolutoin onresolutionTarget - target resolution
public static boolean checkOrCreateResolution(info.magnolia.cms.core.Content media,
String resolutionTarget,
String nodeDataName)
media - media to check the resolution onresolutionTarget - target resolutionnodeDataName - nodedata where the image to resize is stored
protected static info.magnolia.cms.core.Content getResolutionsNode(info.magnolia.cms.core.Content media)
media -
public static BufferedImage getImageForResolution(BufferedImage original,
String resolution,
Map<String,String> params)
original - original imageresolution - resolutionparams - parameters
public static String getExtension(info.magnolia.cms.core.Content media,
String resolution)
media - mediaresolution - resolution
public static BufferedImage createBufferedImage(info.magnolia.cms.core.NodeData image)
image - nodedata
public static Point parseForSize(String res)
res - resolution string
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||