Android--Exif

Source: Internet
Author: User

Exif

EXIF is an image file format, its data is stored in the JPEG format is exactly the same, in fact, the EXIF format is the JPEG format header inserted digital photo information, including the shooting aperture, shutter, balance white, ISO, focal length, date and time and other various and shooting conditions and camera brand, model, Color coding, GPS and so on.

Exifinterface

Under Android, the EXIF information of the picture is manipulated through the Exifinterface class, although the name of this class contains interface, but it is not an interface, it is a class, under the "Android.media.ExifInterface" package, is the implementation of a part of the Media Library feature. Exifinterface has a constructor that accepts a string type of data, which is the address of the image file to be read.

EXIF data in the picture can be understood as Key-value key-value pairs of the way to store, generally by the following several methods of operation:

String getattribute (String tag)// Gets the string value of the property in the picture as tag.  Double getattribute (String tag,double defaultvalue)// gets the double value of the property in the picture as tag.  int getattributeint (String tag,defaultvalue// gets the int value of the property in the picture as tag.  void setAttribute (String tag,string value)// The value of the image Exif is set according to the input parameters.  void saveattrubutes ()// The EXIF of the in-memory picture is written to the picture. 

To see, most of the above methods manipulate a string type of the tag parameter, this is the EXIF attribute, in Exifinterface defines some string static constants to represent these tag values, commonly used as follows:

Tag_aperture//The aperture value. Tag_datetime//The time taken depends on the time the device is set. Tag_exposure_time//exposure time. Tag_flash//Flash. Tag_focal_length//focal length. Tag_image_length//picture height. Tag_image_width//picture width. Tag_iso//ISO. Tag_make//Equipment brands. Tag_model//The device model, the shaping representation, has a constant corresponding representation in the exifinterface. Tag_orientation//The rotation angle, the shape representation, has the constant corresponding representation in the exifinterface. 
Get EXIF
Exifinterface Exifinterface =NewExifinterface ("/sdcard/a.jpg"); String Ffnumber=Exifinterface.getattribute (exifinterface.tag_aperture); String Fdatetime=Exifinterface.getattribute (exifinterface.tag_datetime); String Fexposuretime=Exifinterface.getattribute (exifinterface.tag_exposure_time); String Fflash=Exifinterface.getattribute (Exifinterface.tag_flash); String Ffocallength=Exifinterface.getattribute (exifinterface.tag_focal_length); String Fimagelength=Exifinterface.getattribute (exifinterface.tag_image_length); String Fimagewidth=Exifinterface.getattribute (exifinterface.tag_image_width); String fisospeedratings=Exifinterface.getattribute (Exifinterface.tag_iso); String Fmake=Exifinterface.getattribute (Exifinterface.tag_make); String Fmodel=Exifinterface.getattribute (Exifinterface.tag_model); String forientation=Exifinterface.getattribute (exifinterface.tag_orientation); String fwhitebalance= Exifinterface.getattribute (exifinterface.tag_white_balance);
Write EXIF

EXIF information in the picture is stored in binary form, the number of bits stored in each field is fixed, and the number of tags is fixed, so we can only manipulate the image EXIF information already exists in the value of the tag, and the data to be stored in accordance with the limit of the number of storage bits, If the stored data type is wrong, the stored data may not be properly fetched and the number of digits exceeded will be intercepted. If the data of a string cannot be stored in tag_orientation, it must store the value of type int, and the extra will be intercepted.

// Tag String strattr = exifinterface.tag_orientation; // Tag-value String strvalue = et_value.gettext (). toString (). Trim (); // get pictures of Exif New Exifinterface ("/sdcard/a.jpg"); // Save the value of the specified tag Exif.setattribute (strattr,strvalue); // The EXIF information is written to the target image Exif.saveattributes ();
I'm the dividing line of the king of the Land Tiger.

Android--Exif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.