How to get all details of an image pragmatically available in Android phone gallery
you can use android's ExifInterface for doing this.
This is a class for reading and writing Exif tags in a JPEG file or a RAW image file.
Supported formats are: JPEG, DNG, CR2, NEF, NRW, ARW, RW2, ORF and RAF.
Refer it from here Android ExifInterface
Get Meta Data of Image - Android
Download metadata extractor from the link given here ...... click to download the library
choose the version 2.5.0.RC-3.zip
Extract the jar Folder
and import jar into libs folder in your poject and then execute the below code
try {
InputStream is = new URL("your image url").openStream();
BufferedInputStream bis = new BufferedInputStream(is);
Metadata metadata = ImageMetadataReader.readMetadata(bis,true);
for (Directory directory : metadata.getDirectories()) {
for (Tag tag : directory.getTags()) {
System.out.println(tag);
}
}
}
catch (ImageProcessingException e){}
catch (IOException e) {}
reading android jpeg EXIF metadata from picture callback
The bad news:
Android Api sadly won't allow you to read exif data from a Stream
, only from a File
.
ExifInterface don't have a constructor with an InputStream
.
So you must parse jpeg content by yourself.
The good news:
API exists in pure Java for this. You can use this one: https://drewnoakes.com/code/exif/
It's Open Source, published under Apache Licence 2 and available as a Maven package.
There is a constructor with an InputStream
:public ExifReader(java.io.InputStream is)
You can build an InputStream
backed by your byte[]
using a ByteArrayInputStream
like this:
InputStream is = new ByteArrayInputStream(decodedBytes);
Writing EXIF metadata to images in Android
Ok, Somebody (offline) pointed me to a useful resource. The ExifInterface
looks like what I was searching for. Android-er has a post demonstrating how to read EXIF metadata in Android and I think writing should not be very different.
I don't know, but can we EXIF to write arbitrary metadata, ie. other than those specified in the ExifInterface documentation (like latitude, longitude, flash etc). If not, what could be a preferred method of writing arbitrary metadata to image files?
Thanks
I want to read exif info in image in android. I can read exif from image in gallery but i cannot read exif photo taken from the camera
You cannot read exif data from a Stream using the android api. ExifInterface doesn't have a constructor with an InputStream.
However, You can use the metadata-extractor
and use the constructor with an InputStream to build an InputStream backed by your byte[] using a ByteArrayInputStream
Related Topics
How Is an Intent Service Declared in the Android Manifest
What Is Use of Cursor in Android Development
HTML5 <Video> Element on Android Does Not Play
Firebase - How to Delete Many Entries at Once
How to Add a Button at The End of Recyclerview
How to Load The Listview "Smoothly" in Android
CSS Reference to Phone's Emoji Font
How to Convert Date Format in Android
Set Rowspan or Colspan of a Child of a Gridlayout Programmatically
Download Images Using Android Webview
Generating Edit Text Programmatically in Android
How to Set Text Color of a Textview Programmatically
How to Set Up Gradle and Android Studio to Do Release Build
Android Browser Textarea Scrolls All Over The Place, Is Unusable