com.photoviewer.server.util
Class JPEGResizer

java.lang.Object
  extended bycom.photoviewer.server.util.JPEGResizer

public class JPEGResizer
extends java.lang.Object

JPEGResizer's sole purpose is to take a source JPEG and return a resized (usually smaller) version. I implemented the code in Java, instead of using an external graphics conversion program, because I didn't want to require any external programs necessary to generate the web site.

Author:
Chris Normand

Field Summary
protected  float m_jpegLevel
           
protected  int m_maxDimension
           
 
Constructor Summary
JPEGResizer(int max)
           
JPEGResizer(int max, float jl)
           
 
Method Summary
protected  java.awt.image.BufferedImage readImage(java.io.File file)
           
protected  java.awt.image.BufferedImage readImage(java.io.FileInputStream in)
           
protected  java.awt.image.BufferedImage readImage(java.lang.String filename)
           
protected  java.awt.image.BufferedImage resize(java.awt.image.BufferedImage image)
          The workhorse method.
protected  java.awt.image.BufferedImage resize(java.io.File file)
           
protected  java.awt.image.BufferedImage resize(java.lang.String filename)
           
 long resizeAndSave(java.io.File source, java.io.File dest)
           
 long resizeAndSave(java.lang.String source, java.lang.String dest)
           
protected  void saveJPEG(java.awt.image.BufferedImage image, java.io.File file)
           
protected  void saveJPEG(java.awt.image.BufferedImage image, java.io.FileOutputStream out)
           
protected  void saveJPEG(java.awt.image.BufferedImage image, java.lang.String filename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_maxDimension

protected int m_maxDimension

m_jpegLevel

protected float m_jpegLevel
Constructor Detail

JPEGResizer

public JPEGResizer(int max)

JPEGResizer

public JPEGResizer(int max,
                   float jl)
Method Detail

readImage

protected java.awt.image.BufferedImage readImage(java.io.File file)
                                          throws java.lang.Exception
Throws:
java.lang.Exception

readImage

protected java.awt.image.BufferedImage readImage(java.io.FileInputStream in)
                                          throws java.lang.Exception
Throws:
java.lang.Exception

readImage

protected java.awt.image.BufferedImage readImage(java.lang.String filename)
                                          throws java.lang.Exception
Throws:
java.lang.Exception

resize

protected java.awt.image.BufferedImage resize(java.awt.image.BufferedImage image)
                                       throws java.lang.Exception
The workhorse method. It takes a buffered image and resizes it based on the m_maxDimension value. Added code so that images are NOT stretched to m_maxDimension.

Throws:
java.lang.Exception

resize

protected java.awt.image.BufferedImage resize(java.io.File file)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

resize

protected java.awt.image.BufferedImage resize(java.lang.String filename)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

resizeAndSave

public long resizeAndSave(java.io.File source,
                          java.io.File dest)
                   throws java.lang.Exception
Throws:
java.lang.Exception

resizeAndSave

public long resizeAndSave(java.lang.String source,
                          java.lang.String dest)
                   throws java.lang.Exception
Throws:
java.lang.Exception

saveJPEG

protected void saveJPEG(java.awt.image.BufferedImage image,
                        java.io.File file)
                 throws java.lang.Exception
Throws:
java.lang.Exception

saveJPEG

protected void saveJPEG(java.awt.image.BufferedImage image,
                        java.io.FileOutputStream out)
                 throws java.lang.Exception
Throws:
java.lang.Exception

saveJPEG

protected void saveJPEG(java.awt.image.BufferedImage image,
                        java.lang.String filename)
                 throws java.lang.Exception
Throws:
java.lang.Exception