com.groupdocs.viewer.handlers
Class ImageHandler

java.lang.Object
  extended by com.groupdocs.viewer.handlers.ImageHandler

public class ImageHandler
extends Object

Provides some image manipulation functionality

Author:
Alex Bobkov

Field Summary
static int BOTTOM
           
static int BOTTOM_CENTER
           
static int CENTER
           
static int MIDDLE
           
static int MIDDLE_CENTER
           
 
Constructor Summary
ImageHandler()
           
 
Method Summary
static void addCaption(InputStream inputStream, OutputStream outputStream, String text, String color, Integer fontSize, int position)
          Add caption
Adds caption message to the specified position of each page
static void addCaption(String imagePath, String text, String color, Integer fontSize, int position)
          Add caption
Adds caption message to the specified position of each page
static void addEvaluationMessage(InputStream inputStream, OutputStream outputStream)
          Add evaluation message
Adds evaluation message to the top of each page
static void addEvaluationMessage(String imagePath)
          Add evaluation message
Adds evaluation message to the top of each page
static void addWatermark(InputStream inputStream, OutputStream outputStream, String text, String color, Integer fontSize, String position)
          Add watermark
static void addWatermark(String imagePath, String text, String color, Integer fontSize, String position)
          Add watermark
static Color parseColor(String color)
          Parse color
static void resize(String imagePath, int width)
          Resize image with desired width
On resize image ration is kept
static void resize(String originalImagePath, String newImagePath, int width)
          Resize image with desired width and store it in new location
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
See Also:
Constant Field Values

MIDDLE

public static final int MIDDLE
See Also:
Constant Field Values

MIDDLE_CENTER

public static final int MIDDLE_CENTER
See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
See Also:
Constant Field Values

BOTTOM_CENTER

public static final int BOTTOM_CENTER
See Also:
Constant Field Values
Constructor Detail

ImageHandler

public ImageHandler()
Method Detail

resize

public static void resize(String imagePath,
                          int width)
                   throws Exception
Resize image with desired width
On resize image ration is kept

Parameters:
imagePath - Path to image file
width - New width
Throws:
Exception

resize

public static void resize(String originalImagePath,
                          String newImagePath,
                          int width)
                   throws Exception
Resize image with desired width and store it in new location

Parameters:
originalImagePath - Path to original image
newImagePath - Path to new image location
width - New width
Throws:
Exception

addWatermark

public static void addWatermark(String imagePath,
                                String text,
                                String color,
                                Integer fontSize,
                                String position)
Add watermark

Parameters:
imagePath - absolute path to image file
text - watermark text
color - watermark color
Acceptable values:
- \#fff000
- Red (Blue, White, etc)
- rgb(0,0,0)
- rgba(0,1,2,0.5)
fontSize - watermark font size
position - watermark position
Acceptable values:
- horizontal - vertical - diagonal

addWatermark

public static void addWatermark(InputStream inputStream,
                                OutputStream outputStream,
                                String text,
                                String color,
                                Integer fontSize,
                                String position)
Add watermark

Parameters:
inputStream - file to read
outputStream - file to write
text - watermark text
color - watermark color
Acceptable values:
- \#fff000
- Red (Blue, White, etc)
- rgb(0,0,0)
- rgba(0,1,2,0.5)
fontSize - watermark font size
position - watermark position
Acceptable values:
- horizontal - vertical - diagonal

addEvaluationMessage

public static void addEvaluationMessage(String imagePath)
Add evaluation message
Adds evaluation message to the top of each page

Parameters:
imagePath - absolute path to image file

addEvaluationMessage

public static void addEvaluationMessage(InputStream inputStream,
                                        OutputStream outputStream)
Add evaluation message
Adds evaluation message to the top of each page

Parameters:
inputStream - file to read
outputStream - file to write

addCaption

public static void addCaption(String imagePath,
                              String text,
                              String color,
                              Integer fontSize,
                              int position)
Add caption
Adds caption message to the specified position of each page

Parameters:
imagePath - absolute path to image file
text - message
color - color (null for default)
Acceptable values:
- \#fff000
- Red (Blue, White, etc)
- rgb(0,0,0)
- rgba(0,1,2,0.5)
fontSize - font size (null for default)
position - position on page where message will be added
Values:
ImageHandler.CENTER
ImageHandler.MIDDLE
ImageHandler.MIDDLE_CENTER
ImageHandler.BOTTOM
ImageHandler.BOTTOM_CENTER

addCaption

public static void addCaption(InputStream inputStream,
                              OutputStream outputStream,
                              String text,
                              String color,
                              Integer fontSize,
                              int position)
Add caption
Adds caption message to the specified position of each page

Parameters:
inputStream - file to read
outputStream - file to write
text - message
color - color (null for default)
Acceptable values:
- \#fff000
- Red (Blue, White, etc)
- rgb(0,0,0)
- rgba(0,1,2,0.5)
fontSize - font size (null for default)
position - position on page where message will be added
Values:
ImageHandler.CENTER
ImageHandler.MIDDLE
ImageHandler.MIDDLE_CENTER
ImageHandler.BOTTOM
ImageHandler.BOTTOM_CENTER

parseColor

public static Color parseColor(String color)
Parse color

Parameters:
color - string color
Acceptable values:
- \#fff000
- Red (Blue, White, etc)
- rgb(0,0,0)
- rgba(0,1,2,0.5)
Returns:
color


Copyright © 2014. All rights reserved.