Creating Thumbnails of Images without AWT

I've searched in a lot of places, and am becoming increasingly surprised I cannot find a straightforward answer to a problem I have. I run Tomcat on a server which has no X11, and I do not want to install it. However, I am also trying to create a servlet which will take an image from a byte array and create a thumbnail of it.

While I have seen many examples of this, all use AWT, which seems to require using X11 or some windowing system even to run at all (despite my not trying to create a window or anything). While I understand that there is an option that can be added to the initialization script for Tomcat ("JAVA_OPTS=-Djava.awt.headless=true") I would far prefer simple code that didn't use AWT at all.

Does anyone know how to create a thumbnail or resize an image without the use of the AWT library whatsoever? Thanks very much!

[861 byte] By [quantescapea] at [2007-11-26 21:38:24]
# 1
Take a look at this: http://java.about.com/library/weekly/aa_img_resize.htmI don't think they've used AWT anywhere.I found it upon searching for "java image resize" on Google.
appy77a at 2007-7-10 3:21:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
That article is good; unfortunately ParameterBlock is in AWT (java.awt.image.renderable.ParameterBlock). It's crucial, even in that article, to the resize operation.
quantescapea at 2007-7-10 3:21:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Hmm... sorry I didn't know that.

I remember seeing some section on this website about Java Imaging or something like that and it seemed totally independent of AWT.

I came accross another imaging article:

http://johnbokma.com/java/obtaining-image-metadata.html , this one doesn't seem to use AWT - at least I don't see any in the imports.

May be Images are supposed to work only with AWT.

Here's another set of examples:

http://www.exampledepot.com/egs/javax.imageio/pkg.html

that demonstrates the javax.imageio package, but those examples also use AWT.

I think one could re-size an image on a website to create thumbnails, by specifying a percent width and height. and may be there's no need to have a package to create thumbnails on a web page when it could be done with HTML and that's probably why there isn't image processing for web pages (this is just my guess work, I could be wrong)

Message was edited by:

appy77

appy77a at 2007-7-10 3:21:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

You might want to take a look at Image Tags:

This JSP tag library generates and transforms images dynamically. It exposes some of the imaging capability available in Java2D, Java Advanced Imaging, ImageIO, etc., as a set of tags.

http://jakarta.apache.org/taglibs/sandbox/doc/image-doc/intro.html

appy77a at 2007-7-10 3:21:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I ran into this problem several years ago. There's a GPL package called the [url= http://www.eteks.com/pja/en/]PJA Toolkit[/url] that you can plug in to the jvm to give you the ability to make AWT calls in a headless environment.
bckrispia at 2007-7-10 3:21:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...