views:

54

answers:

1

The following link shows the list of directories where the thumbnails are stored in the respective phones: http://wiki.forum.nokia.com/index.php/Thumbnail_path_for_3rd_edition_devices

but the phones given on the link are limited. Does it mean that, for other phones (such as N86, Expressmusic etc), I do not have access to thumbnails? I tried using all the directory structures given on the link, but none are working for the mentioned phones. Does anybody know anything about it?

A: 

I don't know if it is what you need, but you can fetch embedded thumbnail out of full-size JPEG file. In my j2me application I show the phone gallery this way.

private final static int STOP_AT_BYTE = 8192;   //how far to search for thumbnail
private final static int THUMB_MAX_SIZE = 16284; 

private Image getThumbnailFromStream(InputStream str, long fileSize)
{
    byte[] tempByteArray = new byte[THUMB_MAX_SIZE]; // how big can a thumb get.
    byte[] bytefileReader = {0}; // lazy byte reader
    byte firstByte,secondByte = 0;
    int currentIndex = 0;

    int currByte = 0;

    try {
        str.read(bytefileReader);
        firstByte = bytefileReader[0];
        str.read(bytefileReader);
        secondByte = bytefileReader[0];

        currByte += 2;

        if ((firstByte & 0xFF) == 0xFF && (secondByte & 0xFF) == 0xD8) {    //if this is JPEG
            byte rByte = 0;
            do {
                while (rByte != -1 && currByte < fileSize) {
                    str.read(bytefileReader);
                    rByte = bytefileReader[0];
                    currByte++;
                }

                str.read(bytefileReader);
                rByte = bytefileReader[0];
                currByte++;

                if (currByte > STOP_AT_BYTE) {
                    return null;
                }
            } while ((rByte & 0xFF) != 0xD8 && currByte < fileSize); // thumb starts

            if (currByte >= fileSize) {
                return null;
            }

            tempByteArray[currentIndex++] = -1;
            tempByteArray[currentIndex++] = rByte;
            rByte = 0;

            do {
                while (rByte != -1){
                    str.read(bytefileReader);
                    rByte = bytefileReader[0];
                    tempByteArray[currentIndex++] = rByte;
                }

                str.read(bytefileReader);
                rByte = bytefileReader[0];
                tempByteArray[currentIndex++] = rByte;
            } while ((rByte & 0xFF) != 0xD9); // thumb ends

            tempByteArray[currentIndex++] = -1;
            Image image = Image.createImage(tempByteArray, 0, currentIndex-1);
            tempByteArray = null;

            return image;
        }
    } catch (Throwable e) {
        //error
    }

    return null;
}
Pavel Alexeev
Hi Pavel,Thanks for your reply. Can you please be a little elaborate on what do you mean by fetching embedded thumbnail out of full size JPEG file? Right now, I need a way to either find the path of the thumbnail or to compress the full size image in the gallery in my code. Any suggestion will be appreciated..Thanks,Ashish.
See http://www.media.mit.edu/pia/Research/deepview/exif.html.All you need is to read your full-size image byte-by-byte until you find 0xFFD8 marker. This will be beginning of embedded thumbnail.
Pavel Alexeev
I attach my code :)
Pavel Alexeev
Hi Pavel, thank you very much! btw, I had a Russian friend in NUS named Pavel as well.. You just reminded me of him! thanks for the code! :)Also, generally in Nokia phones, there are two thumbnails stored, one small and one slightly big. Are both the thumbnails stored in the full size JPEG file? or is there any other way to get the smaller thumbnail?Thanks once again,Regards,Ashish.
I dont know - you can take a photo and check. I think that size of thumbnail depends on device.
Pavel Alexeev