Return to the iSJava Tips
TIF to JPEG Conversion Utility
From: ******************* WebSpherePro Developer Tips ******************* Published by e-Pro Magazine http://www.e-ProMag.com Issue 52 Editor: Don Denoncourt November 6, 2003 TO SUBSCRIBE, go to http://www.e-ProMag.com/epsubscriptions . I just completed a Web Services project where electronic copies of checks and other banking documents are retrieved for HTML display. The problem was that the images were in TIF format and a plug-in is required to display TIF images in a browser. We didn't want to force clients to install a plug-in, so we opted to convert the images from TIF to JPEG. There are a number of such conversion utilities available, both open-source and commercial, but by far the easiest to use is Sun's Jimi Software Development Kit ( http://java.sun.com/products/jimi/ ). Here's a quick tutorial. "From" is the qualified name of a TIF image and "to" is the qualified name (with a .jpg suffix) of a JPEG that is to be created: Image image = Jimi.getImage(from); Jimi.putImage(image, to); I'd say that was pretty easy! One big issue that I had with Jimi was that it used java.awt classes during the conversion and my target platform, the iSeries, has issues with AWT on the server. Those issues are surmountable, but until recently, the solution requires the clunky use of Remote AWT (RAWT) or Native (AWT). But a combination of OS/400 V5R2 and JDK 1.4 resolved that problem. JDK 1.4 now has an option called "headless AWT." The term headless refers to the lack of a requirement for a terminal, or head, to display the image. To use headless AWT, all you need to do is set the java.awt.headless property to true. There are a number of ways to set Java property values, the easiest of which is to pass them to the following Java command: java -Djava.awt.headless=true
[report a broken link by clicking here]