Friday, December 08, 2006

EXIF extraction for J2ME

I've been struggling with creating thumbnails in J2ME—not that it's hard to do—but given the limited heapsize and mobile handsets' processor capability, the traditional Java (J2SE) thumbnail-generation process fails when the picture whose thumbnail about to be generated is HUGE (eg. those created by >2 megapixel cameraphones).

In general, there are few approaches:

1. generate your own thumbnail (good for smaller JPEG pictures & PNG formats)
2. read (hidden?) thumbnail directories that some handsets create
3. try to extract thumbnail inside EXIF header of some JPEG pictures

The 2nd & 3rd options don't always work for all phones. Problem with #2 is that only on some handsets is the picture thumbnail generated into predetermined directories. For #3, some developers claim Nokia cameraphones do not generate JPEG formats with EXIF headers in it. Sony-Ericsson phones do, however!

So this is the original Java library that I used to extract the EXIF header and obtain the thumbnail offset, length and the thumbnail data itself. It needs porting, however, to be able to run on J2ME. I've ported it into J2ME and the (crude!) source for the test midlet is here. Some sample pictures can be found at the original site.

More information about EXIF tags can be found here, in case you'd like to tinker with more exciting information! If anyone comes to this blog by searching for this, please feel free to download it & use as you like. Original code is copyrighted and it belongs to Drew Noakes.

I hope this helps some people out there.

UPDATE! (Apr 1 '2009):
The domain where the source is hosted has expired ;) I have updated the link to point here: http://blvu.com/exif-j2me-src.zip

16 comments:

Anonymous said...

Thanks, I will try it :)

Anonymous said...

Worked for me - many thanks! This metadata library translates into roughly 60kBytes in the JAR.

Guy Nicholson said...

I used the code in an application UTM converter to read coordinates contained in geotagged JPG image files - thanks.

Anonymous said...

hi am getting problem wen compile the given src in download link.

like:
import junit.framework.TestCase;
..

plz help as
thanks

Anonymous said...

If you don't leave your name nor email, how can I help you? :)

Anyway, you need to have JUnit (jar) in your path.

Anonymous said...

still am getting same error,am JUnit.jar copied in lib folder in wtk.
please send me mail on naresh.durgam08@gmail.com

thanks

Anonymous said...

Hi,

I'm trying to download the source code example too, but I'mm getting an error.

Could please send it to me to ferplalop@gmail.com??

Thanks a lot!!

Unknown said...

Hi Antonia

It's me Adrian. I've contacted you about the Exif S60 application. I just want to know if you still want to do it. Please reply me!

Anonymous said...

Merci beaucoup!

Anonymous said...

hi,
I have some problems with compilation:

Error: cannot find symbol method initCause(java.lang.ClassNotFoundException)

this line cause error

JpegDirectory directory = (JpegDirectory)metadata.getDirectory(JpegDirectory.class);

Antonia said...

To all the ANONYMOUS out there: PLEASE LEAVE YOUR EMAIL!

Otherwise how can I help you?

To the Last anonymous: check your classpath first...

Mohammed Suhail said...

Hi

I cannot run the source code that u posted. I used it netbeans ide and its just showing the test screen when run and nothing else. what 2 do.....
also i used the available Jmunitin the IDE.
how to run it on mobile phones.
please help.

my email is suhailmo@gmail.com

Unknown said...

Hello Antonia.
Can you explain me how to integrate your sorce code with my project ?

I use netbeans 6.9
My mail adress is:

vindam81@gmail.com

Thanks in advance and sorry for my bad english

Eko said...

GOD!
This save my day

Thankx bro!

rossa said...

hi antonia. could you give me the source, i can not open http://blvu.com/exif-j2me-src.zip.
thanks

Antonia said...

rossa,

You can check it out at:
http://code.google.com/p/exif-j2me/

Antonia