Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is MINI_THUMB_MAGIC and how to use it?

Background

I've noticed a weird column for MediaStore.Images.ImageColumns called "MINI_THUMB_MAGIC" .

the documentation says just that :

The mini thumb id.

Type: INTEGER

Constant Value: "mini_thumb_magic"

The question

my guess is that this field is related to MediaStore.Images.Thumbnails .

Is it correct ? if not, what is this and how do you use it?

if it is correct , i have other questions related to it:

  1. Is it a mini sized image of the original one? does it use the same aspect ratio or does it do center-cropping on it?

  2. how come the size of "MICRO" is square (96 x 96) and the size of "MINI" is a non-square rectangle ( 512 x 384 ) ?

  3. How do you use it? My guess is that it's done by using "THUMB_DATA", which is a blob, so you use it like this, but then what is the purpose of using "getThumbnail" if you already have this field?

  4. does it get a rotated thumbnail in case the orientation value is not 0 ? meaning that if I wish to show it, I won't need to rotate the image?

  5. Is it possible to do a query of the images together with their thumbnails? maybe using inner join?

  6. Is it available for all Android devices and versions?

  7. Why is it even called "magic" ? Is it because it's also available for videos (and for some reason doesn't exist for music, as it could be the album's cover photo, for example) ?

like image 876
android developer Avatar asked Jan 23 '14 15:01

android developer


1 Answers

Check this file: https://github.com/android/platform_packages_providers_mediaprovider/blob/master/src/com/android/providers/media/MediaThumbRequest.java in the Android source code. This value is some magic number which allows to determine if the thumbnail is still valid. I didn't investigate that file further, but it should be no bit issue to dive deeper. To your questions:

  1. No, no mini-sized image
  2. Well, I guess it's a definition by Google who want to have a square thumbnail for some lists, where only very small previews should be visible and where many items should fit on the screen and there's another thumbnail format where the images are bigger...
  3. I don't know that, but according to Google's doc, one (THUMB_DATA) is only some raw byte array of the thumbnail (dunno in which format) and the other one (getThumbnail) retrieves a full-fledged bitmap object...
  4. don't know
  5. don't know
  6. I guess so, as it's part of AOSP source code.
  7. The word "magic" is often used for some kind of identifier. There are "magic packets" who can wake up a computer from sleep or shutdown over the network, there are magic numbers on hard disks, where some sectors (e.g. the MBR) has the hexadecimal values AA 55 on its last two byte positions, there are also magic numbers in image files which help software packages determine the image type (e.g. GIF files begin with GIF89a or GIF87a (ASCII), JPEG files begin with FF D8 hexadecimal) and there are many, many more examples. So, magic numbers are a very common term here :-)
like image 146
TomS Avatar answered Oct 13 '22 03:10

TomS