com.mancrd.ahah.commons.utils
Class ImageUtils

java.lang.Object
  extended by com.mancrd.ahah.commons.utils.ImageUtils

public final class ImageUtils
extends Object

Author:
timmolter

Method Summary
static BufferedImage createThumbnail(BufferedImage pBufferedImage, int pSize)
          Creates a Thumbnail of an image, maintaining the aspect ratio, and scaling the largest dimension to pSize
static BufferedImage fillTransparentPixels(BufferedImage image, Color fillColor)
           
static BufferedImage getBufferedImageFromFile(File pFile)
          Creates a BufferredImage give a File
static BufferedImage getBufferedImageFromURL(String imageUrl)
          Generates a BufferedImage from a given URL
static Dimension getImageSizeWithoutFullDownload(URL url, int timeout)
           
static byte[] getJpegImageByteArray(BufferedImage bufferedImage, float quality)
           
static String getMD5Hash(BufferedImage pBufferedImage)
          Generates a MD5 Hash for a given Bufferred Image
static int[] getPixelARGB(int pixel)
           
static int getPixelInt(int a, int r, int g, int b)
           
static boolean saveByteArrayToJpeg(byte[] imageInBytes, String path, String name)
           
static boolean saveImage(BufferedImage pBufferedImage, String pPath, String pName, String pFileExtension)
           
static boolean saveJPG(BufferedImage pBufferedImage, String pPath, String pName)
           
static boolean saveJPGWithQuality(BufferedImage pBufferedImage, String pPath, String pName, float quality)
           
static boolean savePNG(BufferedImage pBufferedImage, String pPath, String pName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

saveJPGWithQuality

public static boolean saveJPGWithQuality(BufferedImage pBufferedImage,
                                         String pPath,
                                         String pName,
                                         float quality)

getJpegImageByteArray

public static byte[] getJpegImageByteArray(BufferedImage bufferedImage,
                                           float quality)

saveByteArrayToJpeg

public static boolean saveByteArrayToJpeg(byte[] imageInBytes,
                                          String path,
                                          String name)

fillTransparentPixels

public static BufferedImage fillTransparentPixels(BufferedImage image,
                                                  Color fillColor)

savePNG

public static boolean savePNG(BufferedImage pBufferedImage,
                              String pPath,
                              String pName)

saveJPG

public static boolean saveJPG(BufferedImage pBufferedImage,
                              String pPath,
                              String pName)

saveImage

public static boolean saveImage(BufferedImage pBufferedImage,
                                String pPath,
                                String pName,
                                String pFileExtension)

getPixelARGB

public static int[] getPixelARGB(int pixel)

getPixelInt

public static int getPixelInt(int a,
                              int r,
                              int g,
                              int b)

getBufferedImageFromURL

public static BufferedImage getBufferedImageFromURL(String imageUrl)
Generates a BufferedImage from a given URL

Parameters:
imageUrl -
Returns:
BufferedImage - returns null and logs and error if there was a problem

getImageSizeWithoutFullDownload

public static Dimension getImageSizeWithoutFullDownload(URL url,
                                                        int timeout)

createThumbnail

public static BufferedImage createThumbnail(BufferedImage pBufferedImage,
                                            int pSize)
Creates a Thumbnail of an image, maintaining the aspect ratio, and scaling the largest dimension to pSize

Parameters:
pBufferedImage -
pSize -
Returns:

getBufferedImageFromFile

public static BufferedImage getBufferedImageFromFile(File pFile)
Creates a BufferredImage give a File

Parameters:
pFile -
Returns:

getMD5Hash

public static String getMD5Hash(BufferedImage pBufferedImage)
Generates a MD5 Hash for a given Bufferred Image

Parameters:
pBufferedImage -
Returns:
String - a 32 char String representing the MD5 hash of the image.


Copyright © 2013–2014 M. Alexander Nugent Consulting, Research and Devlopment. All rights reserved.