com.atlassian.studio.jira.web.util
Class ImageUtils

java.lang.Object
  extended by com.atlassian.studio.jira.web.util.ImageUtils

public final class ImageUtils
extends Object

Utilities for resizing and cropping images

Author:
jwilson

Method Summary
static BufferedImage boxCropImage(BufferedImage image, int sideLength)
          Takes an image and returns a square image of size sizeLength If the image is larger then the specified sizeLength then the image is scaled down to the closest size and then cropped.
static BufferedImage scaleImage(BufferedImage image, int width, int height)
          Scales an image to the specified width and height.
static BufferedImage scaleImageToMaxHeight(BufferedImage image, int maxHeight)
          Scales an image down to the specified maxHeight.
static BufferedImage scaleImageToMaxWidth(BufferedImage image, int maxWidth)
          Scales an image down to the specified maxWidth.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

scaleImageToMaxHeight

public static BufferedImage scaleImageToMaxHeight(BufferedImage image,
                                                  int maxHeight)
Scales an image down to the specified maxHeight. If the image height is smaller than the maxHeight then the original image is returned. If the maxHeight is larger then the image height then the width is scaled down to the ratio of the image height and maxHeight

Parameters:
image - the image scale
maxHeight - the maximum height for the image.
Returns:

scaleImageToMaxWidth

public static BufferedImage scaleImageToMaxWidth(BufferedImage image,
                                                 int maxWidth)
Scales an image down to the specified maxWidth. If the image width is smaller than the maxWidth then the original image is returned. If the maxWidth is larger then the image width then the height is scaled down to the ratio of the image width and maxWidth

Parameters:
image - the image to scale
maxWidth - the maximum width for the image
Returns:

scaleImage

public static BufferedImage scaleImage(BufferedImage image,
                                       int width,
                                       int height)
Scales an image to the specified width and height. If the width of the image and height of the image are smaller then the ones specified then the original image is returned. If one side of the image is smaller then the scale size then the orignal size is preserved.

Parameters:
image - the image to scale
width - the width to scale the image to
height - the height to scale the image to.
Returns:
the scaled image.

boxCropImage

public static BufferedImage boxCropImage(BufferedImage image,
                                         int sideLength)
Takes an image and returns a square image of size sizeLength If the image is larger then the specified sizeLength then the image is scaled down to the closest size and then cropped. If a side of the image is smaller then sideLength then the sideLength will be ignored and the original size is preserved.

Parameters:
image - the image to crop
sideLength - the size of square that you want the image to be.
Returns:
An image


Copyright © 2002-2012 Atlassian. All Rights Reserved.