JAC project
AOPSYS
CEDRIC & LIP6 labs

org.objectweb.jac.util
Class Thumbnail

java.lang.Object
  |
  +--org.objectweb.jac.util.Thumbnail

public class Thumbnail
extends Object

This class creates thumbnails from bigger images. Useful to have a preview of a photo for example.


Constructor Summary
Thumbnail()
           
 
Method Summary
static void createThumb(byte[] data, int thumbWidth, int thumbHeight, int quality, OutputStream out)
          Create a reduced jpeg version of an image.
static void createThumb(Image image, int thumbWidth, int thumbHeight, int quality, OutputStream out)
          Create a scaled jpeg of an image.
static byte[] createThumbArray(byte[] data, int thumbWidth, int thumbHeight, int quality)
          Create a reduced jpeg version of an image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Thumbnail

public Thumbnail()
Method Detail

createThumbArray

public static byte[] createThumbArray(byte[] data,
                                      int thumbWidth,
                                      int thumbHeight,
                                      int quality)
                               throws Exception
Create a reduced jpeg version of an image. The width/height ratio is preserved.

Parameters:
data - raw data of the image
thumbWidth - maximum width of the reduced image
thumbHeight - maximum heigth of the reduced image
quality - jpeg quality of the reduced image
Returns:
a reduced jpeg image if the image represented by data is bigger than the maximum dimensions of the reduced image, otherwise data is returned
Exception

createThumb

public static void createThumb(byte[] data,
                               int thumbWidth,
                               int thumbHeight,
                               int quality,
                               OutputStream out)
                        throws Exception
Create a reduced jpeg version of an image. The width/height ratio is preserved.

Parameters:
data - raw data of the image
thumbWidth - maximum width of the reduced image
thumbHeight - maximum heigth of the reduced image
quality - jpeg quality of the reduced image
out - produce a reduced jpeg image if the image represented by data is bigger than the maximum dimensions of the reduced image, otherwise data is written to this stream
Exception

createThumb

public static void createThumb(Image image,
                               int thumbWidth,
                               int thumbHeight,
                               int quality,
                               OutputStream out)
                        throws Exception
Create a scaled jpeg of an image. The width/height ratio is preserved.

If image is smaller than thumbWidth x thumbHeight, it will be magnified, otherwise it will be scaled down.

Parameters:
image - the image to reduce
thumbWidth - the maximum width of the thumbnail
thumbHeight - the maximum heigth of the thumbnail
quality - the jpeg quality ot the thumbnail
out - a stream where the thumbnail data is written to
Exception

Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli