Read Exif tag of JPG using ExifInterface(InputStream)

Read Exif tag of JPG using ExifInterface(InputStream) - Hello Friend GENERAL INFO FOR ANDROID DEVELOPMENT, In the article you read this time with the title Read Exif tag of JPG using ExifInterface(InputStream), We have prepared this article for you to read and retrieve information there in. Hopefully the contents of postings Artikel ACTION_OPEN_DOCUMENT, Artikel ExifInterface, We write this you can understand. Alright, good read.

The Title : Read Exif tag of JPG using ExifInterface(InputStream)
link : Read Exif tag of JPG using ExifInterface(InputStream)

Read also


Read Exif tag of JPG using ExifInterface(InputStream)

Last post show how to open image of jpeg using Intent.ACTION_OPEN_DOCUMENT (added in API level 19), then display the image and read the Exif tag using ExifInterface (FileDescriptor)(added in API level 24). Here is another alternative using ExifInterface(InputStream) (added in API level 24) to read Exif.

Simple modify the method showExif(Uri photoUri). All other follow the last example. It have the same result:



void showExif(Uri photoUri){
if(photoUri != null){

/*
How to convert the Uri to InputStream, refer to the example in the document:
https://developer.android.com/guide/topics/providers/document-provider.html
*/

try {
InputStream inputStream = getContentResolver().openInputStream(photoUri);

/*
ExifInterface (InputStream inputStream) added in API level 24
*/
ExifInterface exifInterface = new ExifInterface(inputStream);

String exif="Exif: ";
exif += "\nIMAGE_LENGTH: " +
exifInterface.getAttribute(ExifInterface.TAG_IMAGE_LENGTH);
exif += "\nIMAGE_WIDTH: " +
exifInterface.getAttribute(ExifInterface.TAG_IMAGE_WIDTH);
exif += "\n DATETIME: " +
exifInterface.getAttribute(ExifInterface.TAG_DATETIME);
exif += "\n TAG_MAKE: " +
exifInterface.getAttribute(ExifInterface.TAG_MAKE);
exif += "\n TAG_MODEL: " +
exifInterface.getAttribute(ExifInterface.TAG_MODEL);
exif += "\n TAG_ORIENTATION: " +
exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION);
exif += "\n TAG_WHITE_BALANCE: " +
exifInterface.getAttribute(ExifInterface.TAG_WHITE_BALANCE);
exif += "\n TAG_FOCAL_LENGTH: " +
exifInterface.getAttribute(ExifInterface.TAG_FOCAL_LENGTH);
exif += "\n TAG_FLASH: " +
exifInterface.getAttribute(ExifInterface.TAG_FLASH);
exif += "\nGPS related:";
exif += "\n TAG_GPS_DATESTAMP: " +
exifInterface.getAttribute(ExifInterface.TAG_GPS_DATESTAMP);
exif += "\n TAG_GPS_TIMESTAMP: " +
exifInterface.getAttribute(ExifInterface.TAG_GPS_TIMESTAMP);
exif += "\n TAG_GPS_LATITUDE: " +
exifInterface.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
exif += "\n TAG_GPS_LATITUDE_REF: " +
exifInterface.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF);
exif += "\n TAG_GPS_LONGITUDE: " +
exifInterface.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
exif += "\n TAG_GPS_LONGITUDE_REF: " +
exifInterface.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);
exif += "\n TAG_GPS_PROCESSING_METHOD: " +
exifInterface.getAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD);

inputStream.close();

Toast.makeText(getApplicationContext(),
exif,
Toast.LENGTH_LONG).show();


} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"Something wrong:\n" + e.toString(),
Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"Something wrong:\n" + e.toString(),
Toast.LENGTH_LONG).show();
}

}else{
Toast.makeText(getApplicationContext(),
"photoUri == null",
Toast.LENGTH_LONG).show();
}
};


Next:
Read Exif tag of JPG using ExifInterface(String filename)



Thus Article Read Exif tag of JPG using ExifInterface(InputStream)

The End Article Read Exif tag of JPG using ExifInterface(InputStream) This time, hopefully can give benefits to all of you. well, see you in posting other articles.

You are now reading the article Read Exif tag of JPG using ExifInterface(InputStream) with the link address http://xorislogo.blogspot.com/2017/04/read-exif-tag-of-jpg-using_25.html

0 Response to "Read Exif tag of JPG using ExifInterface(InputStream)"

Post a Comment