Stig Runar Vangen homepage
Blog

Blog

Exporting images from Java

Lately I've been working on image processing for the Wisweb 2 project. I can safely say that the image processing we had in Wisweb 1 will be greatly improved. In addition to adding some new effects I've corrected a lot of bugs in the old version. Some functions also worked fine in the old version, but didn't always give optimal image quality. They will do that now.

The biggest issue I've met so far has been to export the generated images from Java after all processing has been done. This time we want to support correct export of transparent images. In the old version some pictures were in some cases turned opaque instead of transparent after some processing. All image operations does now support transaprent images.

The final piece of the puzzle is the export of images from a completely processed image to something that can be presented in a web browser. To begin with we want to support JPEG, GIF and PNG. There are many solutions out there, and there is not always the simplest or the most obvious solution which are the best. Java 6 does support export to all these formats, but there are some caveats with some of them.

JPEG
  • Java 6 - Top notch export of images. The quality can be fine tuned until you turn blue. Export of JPEG-images in Java has existes as a hidden library in the standard package since.. well.. not too long after the dawn of time, and is incredebly fast.
We decided to use the buildtin Java functionality without more hesitation here.

PNG
  • Java 6 - Pictures are exported perfectly, with correct transparency and all, but.. incredibly slow.
  • Catcode - Images did not preserve its transparency.
  • Objectplanet - Top notch speed, way better than the original. But.. some images got corrupted
The decision fell on the buildtin Java exporter, even though it was not as speedy as we wanted. If anyone knows of any alternative, please drop me a message.

GIF
An another challenge here: Convert true-color to 256 colors (color quantizing), transarency, blending.
  • Java 6 - Images were converted from true-color to an indexed palette, which resulted in a pretty bad color reduction, and lacked transaprency
  • ACME - Does not support color reduction.
  • Gurge - Does not support color reduction.
  • Gif4J - Really good color reduction. Transaprency were exported perfectly. Lacks blending only.
I've contaced the authors of Gif4J with regard to the blending, and got a positive feedback on this. Even without blending their library is the best library available today.
Thursday August 16. 2007

Process module

I've worked a lot on an editor for the process module of Wisweb lately. As a foundation for this module I've used a library called Open-jACOB Draw2D. This editor does not support the features we want out-of-the-box, which resulted in a lot of extra objects being added to this editor. I have to say that the end result looks great, as seen in the screenshot below.

One thing that is really impressive with this library, is its rate of updates. If you look at the project homepage, you'll see that the library has been updated nearly daily. Several of the features we implemented when we started on this project has already been implemented into the library by the original author. Some of these features we would like to add to our version as well, but we'll have to wait and see if more are added before we update the library. With the rate this guy updates this library, we'll be doing updates of this library until the end of days.
Thursday August 9. 2007