Code example for ExifInterface

Methods: getAttributeInt, getThumbnail, hasThumbnail

0
	} 
 
	public static Bitmap getThumbnail(String filePath) {
		ExifInterface exif = null;
		try { 
			exif = new ExifInterface(filePath);
		} catch (IOException e) {
			// TODO Auto-generated catch block 
			// e.printStackTrace(); 
		} 
		Bitmap bm = null;
		if (exif != null && exif.hasThumbnail()) {
			final byte[] thumbnail = exif.getThumbnail();
			bm = BitmapFactory.decodeByteArray(thumbnail, 0, thumbnail.length,
					null); 
			bm = rotateIfNeeded(bm, exif.getAttributeInt(
					ExifInterface.TAG_ORIENTATION,
					ExifInterface.ORIENTATION_UNDEFINED));
 
		} else { 
			Options opts = new Options();
			opts.inSampleSize = 8; // powers of 2 are often good
									// for decoding 
			opts.inPurgeable = true;
			opts.inInputShareable = true;
			opts.inDither = true;
			bm = BitmapFactory.decodeFile(filePath, opts);
			bm = rotateIfNeeded(bm, exif.getAttributeInt(
					ExifInterface.TAG_ORIENTATION,
					ExifInterface.ORIENTATION_UNDEFINED));
		} 
 
		return bm;