Logo of Bento frameworkspaceObject Oriented Programming


JBuilder 2007

ImageUtil

Free source code example for Bento framework...

Seeing is believing! First of all, please enjoy the example of Bento framework that is running on our web site. It is the simple photo Blog where you can upload the image files by your web browser (multipart/form-data), or e-mail with file attachment. After you grasp how it works, please explore its source code. The source code of the example is included in the FREE trial version of Bento framework.

[ Try and download example ... ]

Introduction ...

ImageUtil is the Java API to scale down JPEG, PNG, GIF and WBMP images by JAI (Java Advanced Imaging API). The width/hight of the image can be reduced to fit within the specified rectangle. The ratio of width/height of the original image will be left unchanged. This Java API is useful to show the large image on the small screen of the WAP phone (mobile phone). For instance, Servlet can send the binary contents of the scaled JPEG image to the WAP device.

Do you need BufferedImage?

When the image file is uploaded to your Servlet, its binary contents will be available in JPEG, PNG or GIF format. To manipulate the uploaded image file, those binary contents should be converted to a BufferedImage object. After your Servlet finishes to work on a BufferedImage object, it should be serialized back into the binary contents in JPEG, PNG, GIF or WBMP format to be send back to the web browser or to be stored into the SQL table. ImageUtil implements methods for converting the binary contents in typical image formats to/from a BufferedImage object.

IIOException: Unexpected block type 0! on GIF

Java Image I/O API was introduced in JDK 1.4 . And you can use:

to obtain an ImageReader object for the specific image format. The ImageReader object reads the binary contents from the image file, and returns the BufferedImage object. But, ImageReader for GIF has a bug and throws:

when it reads some GIF files. For details, please read:

Even in case of such a GIF file, ImageUtil can read and return a BufferedImage object. So, this API will be the good workaround for the bug in JDK.

Read Java doc / FREE Download

You can read the Java doc for this API online. Or it is included in the distribution of this API and you can download it at FREE.

Java doc README
Trial License Product License (PDF)
Download

Copyright © 1997-2008 OOP-Research CorporationTM, All Rights Reserved.

Valid XHTML 1.0! Valid CSS!