{% else-1 %}
В метод передаём массив байт изображения. Можно не весь, а первые 50-100 кб.

                        
private Image getThumb(byte[] bt) {
try {
if (((bt[0] & 0xFF) == 0xFF) && ((bt[1] & 0xFF) == 0xD8)) {
int idx = 2;
int hd = 0;
int id0 = 0;
int of0 = 0;
int id1 = 0;
int thof = 0;
int thsz = 0;
int ed = 0;
int fld = 0;

byte[] thumb;
do {// Find the EXIF - 0xFFE1
while (bt[idx] == 0xFF) {
idx++;
}// Found 0xFF, verify the next
idx++;
} while ((bt[idx] & 0xFF) != 0xE1);
// Increases for the next byte, and discard 2 of length
idx += 3;
// EXIF Header size is 6
hd = idx + 6;
ed = (bt[hd] << 8) + bt[hd + 1];
if (ed == 0x4D4D) {
} else if (ed == 0x4949) {
// Gets the IFD0 position. Get from TIFFHeader
id0 = hd + ((((bt[hd + 7] & 0xFF) << 24) + (bt[hd + 6] & 0xFF) << 16) + (bt[hd + 5] & 0xFF) << 8) + (bt[hd + 4] & 0xFF);

// Calculate the Offset to IFD1 position
of0 = id0 + 2 + ((((bt[id0 + 1]) << 8) + (bt[id0])) * 12);
// Extract the IFD1 position
id1 = hd + (((bt[of0 + 3] & 0xFF) << 24) + ((bt[of0 + 2] & 0xFF) << 16) + ((bt[of0 + 1] & 0xFF) << 8) + (bt[of0] & 0xFF));
}
// Get the number of fields in IFD1
fld = ((bt[id1 + 1]) << 8) + (bt[id1]);

for (int i = 0; i < fld; i++) {
int index = i * 12 + 2 + id1;
// Get the Thumbnail Offset and Thumbnail Size
if ((((bt[index + 1]) << 8) + (bt[index])) == 0x0201) {
thof = (((bt[index + 11] & 0xFF) << 24) + ((bt[index + 10] & 0xFF) << 16) + ((bt[index + 9] & 0xFF) << 8) + (bt[index + 8] & 0xFF));
} else if ((((bt[index + 1]) << 8) + (bt[index])) == 0x0202) {
thsz = (((bt[index + 11] & 0xFF) << 24) + ((bt[index + 10] & 0xFF) << 16) + ((bt[index + 9] & 0xFF) << 8) + (bt[index + 8] & 0xFF));
}
}

// Get the thumbnail from the Offset and Size and return it
thumb = new byte[thsz];
for (int i = 0; i < thsz; i++) {
thumb[i] = bt[(idx + 6 + thof + i)];
}
return Image.createImage(thumb, 0, thsz);
}
} catch (Exception ex) {
ex.printStackTrace();
}

return null;
}
0 20 0
Без комментариев...