public class Image extends DBPersist
Simple imaging transformations
Image
,
Serialized FormModifier and Type | Field and Description |
---|---|
static short |
ClassId |
static int |
USE_AWT |
static int |
USE_JAI |
Constructor and Description |
---|
Image()
Create empty image, use AWT imaging routines.
|
Image(java.awt.Image oAWTImage,
java.lang.String sImagePath,
int iLibrary)
Load Image directly from a Java AWT abstract Image
|
Image(int iLibraryCode)
Create empty image.
|
Image(JDCConnection oConn,
java.io.File oFile,
java.lang.String sFilePath)
Load Image properties from database using file path as key.
|
Image(JDCConnection oConn,
java.lang.String sImageId)
Load image properties from database.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
blankGIF()
Get a transparent GIF image that can be served throught a JSP page
Use code like
response.setContentType("image/gif");
OutputStream oOut = response.getOutputStream();
oOut.write(Image.blankGIF());
oOut.flush();
|
byte[] |
createThumbBitmap(int iThumbWidth,
int iThumbHeight,
float fQuality)
Resample image.
|
void |
createThumbFile(java.lang.String sOutputPath,
int iThumbWidth,
int iThumbHeight,
float fQuality)
Resample image.
|
boolean |
delete(JDCConnection oConn)
Delete Image from database and from disk.
|
boolean |
dimensions()
Get image dimensions.
|
java.lang.String |
getImageCodec() |
java.lang.String |
getImageType()
Get image file extension in lowercase.
|
int |
getImagingLibrary()
Get active imaging library.
|
static void |
main(java.lang.String[] argv)
Image command line interface
|
void |
setImagingLibrary(int iLibraryCode)
Set imaging library to use.
|
boolean |
store(JDCConnection oConn)
Store image properties at database.
|
void |
write(java.io.OutputStream oOut)
Encode Image and write it to an OutputStream
|
allcaps, allcaps, clear, clone, columns, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getIntArray, getInteger, getIntegerArray, getIntervalPart, getItemMap, getItems, getMoney, getPrimaryKey, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTime, getTimeOfDay, getTimestamp, isEmpty, isNull, iterator, keySet, load, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, setPrimaryKey, size, toLowerCase, toUpperCase, toXML, toXML, toXML, values
public static final int USE_AWT
public static final int USE_JAI
public static final short ClassId
public Image()
public Image(int iLibraryCode) throws java.lang.IllegalArgumentException
iLibraryCode
- Imaging library to use. Either USE_AWT or USE_JAI.java.lang.IllegalArgumentException
public Image(JDCConnection oConn, java.lang.String sImageId) throws java.sql.SQLException
oConn
- Database Connection.sImageId
- Image GUID at k_images table.java.sql.SQLException
public Image(java.awt.Image oAWTImage, java.lang.String sImagePath, int iLibrary)
oAWTImage
- java.awt.Image objectsImagePath
- Optional. Path to image file name.iLibraryCode
- Imaging library to use. Either USE_AWT or USE_JAI.public Image(JDCConnection oConn, java.io.File oFile, java.lang.String sFilePath) throws java.sql.SQLException
Load Image properties from database using file path as key.
This method searched a file path into field path_image from k_images table.oConn
- Database ConnectionoFile
- Image File ObjectsFilePath
- Full path to Image File (as stored at k_images.path_image)java.sql.SQLException
public void setImagingLibrary(int iLibraryCode)
Set imaging library to use.
On many systems it is neccesary to have X-Windows started for being able to use AWT imaging routines.iLibraryCode
- USE_AWT or USE_JAIhttp://java.sun.com/products/java-media/jai/
,
http://java.sun.com/j2se/1.4.2/docs/api/
public int getImagingLibrary()
Get active imaging library.
public boolean store(JDCConnection oConn) throws java.sql.SQLException, java.lang.UnsatisfiedLinkError, java.lang.NoClassDefFoundError
Store image properties at database.
The image itself is kept as a disk file pointe by path_file field.store
in class DBPersist
oConn
- Database Connectionjava.sql.SQLException
java.lang.NoClassDefFoundError
java.lang.UnsatisfiedLinkError
- hen JAI native libraries (*_jai.so) are not
installed Sun JAI tries to use AWT which is slower but more compatible.
Some libraries of AWT are requiered. Particularly from Fedora Core 2:public boolean delete(JDCConnection oConn) throws java.sql.SQLException
public java.lang.String getImageType()
Get image file extension in lowercase.
public java.lang.String getImageCodec()
public boolean dimensions() throws java.io.IOException, java.io.FileNotFoundException, java.lang.ArrayIndexOutOfBoundsException, java.lang.UnsatisfiedLinkError, java.lang.NullPointerException
Get image dimensions.
Dimensions are stored at dm_width and dm_height properties.java.io.IOException
java.io.FileNotFoundException
java.lang.ArrayIndexOutOfBoundsException
java.lang.NullPointerException
java.lang.UnsatisfiedLinkError
- When JAI native libraries (*_jai.so) are not
installed Sun JAI tries to use AWT which is slower but more compatible.
Some libraries of AWT are requiered. Particularly from Fedora Core 2:public byte[] createThumbBitmap(int iThumbWidth, int iThumbHeight, float fQuality) throws java.lang.NullPointerException, java.io.IOException, java.lang.InterruptedException, java.lang.InstantiationException
Resample image.
iThumbWidth
- Desired widthiThumbHeight
- Desired heightfQuality
- JPG Quality [1..100]java.lang.NullPointerException
java.io.IOException
java.lang.InterruptedException
java.lang.InstantiationException
public void createThumbFile(java.lang.String sOutputPath, int iThumbWidth, int iThumbHeight, float fQuality) throws java.lang.NullPointerException, java.lang.InterruptedException, java.io.IOException, java.lang.InstantiationException
Resample image.
sOutputPath
- File path where generated JPEG shall be saved.iThumbWidth
- Desired widthiThumbHeight
- Desired heightfQuality
- JPG Quality [1..100]java.lang.NullPointerException
java.io.IOException
java.lang.InstantiationException
java.lang.InterruptedException
java.lang.InstantiationException
public void write(java.io.OutputStream oOut) throws java.lang.NullPointerException, java.io.IOException, java.lang.InstantiationException, java.lang.InterruptedException
Encode Image and write it to an OutputStream
oOut
- OutputStreamjava.lang.NullPointerException
- If underlying java.awt.Image object is nulljava.io.IOException
java.lang.InstantiationException
java.lang.InterruptedException
public static byte[] blankGIF()
Get a transparent GIF image that can be served throught a JSP page
Use code like response.setContentType("image/gif"); OutputStream oOut = response.getOutputStream(); oOut.write(Image.blankGIF()); oOut.flush();public static void main(java.lang.String[] argv) throws java.lang.NumberFormatException, java.lang.InstantiationException, java.lang.InterruptedException, java.io.FileNotFoundException, java.io.IOException
Image command line interface
argv
- [jai|awt] thumbnail path_original path_new_thumbnail int_thumb_width int_thumb_height float_qualityjava.lang.NumberFormatException
java.lang.InstantiationException
java.lang.InterruptedException
java.io.FileNotFoundException
java.io.IOException