Photo thumbnail generation in J2ME

I have been working on a photo-application in J2ME. The main challenge turned out to be thumbnail generation. This isn’t really hard to do in the first place, the problem is the limited memory available. Trying to load photos captured with your mobile’s camera will most likely give you memory problems.

There is however one solution, which is to extract the thumbnail stored in the photo’s EXIF. Both Sony Ericsson and Nokia generate and put the thumbnail in the JPEG when you take a photo, but there is of course no guarantee that all photos have one.

The algorithm for extracting the thumbnail should be something like this: (where rByte is the byte you read)

1. Read through byte stream until you get rByte & 0xFF == 0xD8

2. Read thumbnail data until you find rByte & 0xFF == 0xD9

I found the necessary code as part of a slideshow tutorial (look for ImageFunctions.java in the downloadable source code)

Java Service Wrapper

Today I tested Java Service Wrapper by Tanuki Software. Basically it’s software for running your Java application as a service or daemon, and really eases the task of starting, stopping, logging and monitoring your application.

It worked like a dream, and was fairly easy to set up!