Auf dieser Website werden Cookies gesetzt, die für den sicheren Betrieb technisch erforderlich sind. Siehe: Datenschutz

SnTT: Download Images via agent and resize them on a Linux server

by Bernd,
assono GmbH, Standort Hamburg,

How hard could it be to download an image from a web cam and resize it via a scheduled Notes agent? Since Java 1.4 there is the Java Image I/O package with all the necessary classes. After some trials the agent works really fine. At least with a Domino server running under Windows.

If the server is a Linux machine an ugly error message is the output:
java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment

After a little investigation on the web the problem was found. Java Image I/O uses functions from the operating system to download the image and resize it. If the Linux server was setup with no graphical user interface these functions are not available.

The solution for this problem is JIMI. Originally JIMI was developed to process images under Java 1.1.x. There is a free download from Sun:

After the download the archive has to added to the agent with "Edit Project".

The core of the agent has three tasks.

First download the image with the package to the local hard disk.
int pos = this.urlString.lastIndexOf("/");
String filename = this.urlString.substring(pos + 1);
URLConnection con = null;
URL url = new URL(urlString);
con = url.openConnection();
con.setRequestProperty("file-name", filename);
con.setRequestProperty("content-type", "binary/data");

InputStream in = con.getInputStream();

int count;
byte[] buffer = new byte[8192]; // or more ...
while ((count = > 0)
out.write(buffer, 0, count);
out = null;

Then create an image object with the JPEGImageDecoder.
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(new FileInputStream(filename));
image = decoder.decodeAsBufferedImage();

Finally create with JIMI AreaAverageScaleFilter and a JimiWriter a resized version on the local hard disk.
FilteredImageSource filteredImage = new FilteredImageSource (image.getSource (), new AreaAverageScaleFilter (thumbWidth, thumbHeight));
JimiWriter writer = Jimi.createJimiWriter(filePath);
JPGOptions options = new JPGOptions();

Because it is always easier to see a working sample I created a little demo database. wink.gif

Technical article IBM Notes IBM Notes Traveler JavaScript Java

You have questions about this article? Contact us:

Sie wollen eine individuelle Beratung oder einen Workshop? Read more

More interesting entries

Any questions? Contact us.

If you want to know more about our offers, you can contact us at any time. There are several ways to contact us for a non-binding first consultation.

assono GmbH

Location Kiel (headquarters)
assono GmbH
Lise-Meitner-Straße 1–7
24223 Schwentinental

Location Hamburg
assono GmbH
Bornkampsweg 58
22761 Hamburg

Phone numbers:
Human resources department: +49 4307 900 407
Marketing department: +49 4307 900 402

E-Mail adresses: