Read and modify extended JPEG Image Information

Source: Internet
Author: User

 

Reading and writing are key-value pairs. Note that the value type must be strictly in accordance with the api-defined format.

Read/write nodes are supported:

1. TAG_APERTURE: aperture

2. TAG_DATETIME: Date and Time

Type: String, format: "yyyy-MM-dd HH: mm: ss"
3. TAG_EXPOSURE_TIME: Exposure time

4. TAG_FLASH: whether to enable the flashlight

5. TAG_FOCAL_LENGTH: Focal Length
6. TAG_GPS_ALTITUDE: Height

Official interpretation: The altitude (in meters) based on the reference in TAG_GPS_ALTITUDE_REF. Type is rational.

The official interpretation type is rational number. I personally think it should be a positive number (positive integer and positive score) of the double type ).

7. TAG_GPS_ALTITUDE_REF: height reference (above sea level or below sea level)

Type: int. 0 indicates sea level or above, and 1 indicates sea level or below.
8. TAG_GPS_DATESTAMP: Date Stamp

9. TAG_GPS_LATITUDE: latitude

Type: String, Format: Format is num1/denom1, num2/denom2, num3/denom3. location. location. the latitude information obtained by getLatitude () must be converted before being written to this node. The conversion method is listed below.
10. TAG_GPS_LATITUDE_REF: latitude reference (South and North)
11. tag_gps_longpolling: longitude

Same Latitude.
12. tag_gps_longjing: longitude reference (eastern longitude and Western longitude)
13. TAG_GPS_TIMESTAMP: Timestamp
14. TAG_IMAGE_LENGTH: Image Height
15. TAG_IMAGE_WIDTH: Image Width
16. TAG_ISO: Exposure
17. TAG_MAKE: device manufacturer
18. TAG_MODEL: Device Model
19. TAG_ORIENTATION: Direction
20. TAG_WHITE_BALANCE: White Balance

The following example describes how to read and write jpg exif information from Android ExifInterface:

 

// Gps latitude double lat = GpsTracking. bestLocation. getLatitude (); // Gps longitude double lon = GpsTracking. bestLocation. getlongpolling (); try {// get the jpg file ExifInterface exif = new ExifInterface (filePath ++ filename); // write the latitude information exif. setAttribute (ExifInterface. TAG_GPS_LATITUDE, gpsInfoConvert (lat); exif. setAttribute (ExifInterface. TAG_GPS_LATITUDE_REF, lat> 0? N: S); // write the longitude information exif. setAttribute (ExifInterface. tag_gps_long1_, gpsInfoConvert (lon); exif. setAttribute (ExifInterface. TAG_GPS_LONGITUDE_REF, lon> 0? E: W); // This sentence is very important. You must saveAttributes to make the written information take effect. Exif. saveAttributes (); // obtain latitude information String latitude = exif. getAttribute (ExifInterface. TAG_GPS_LATITUDE); // obtain the longitude information String longpolling = exif. getAttribute (ExifInterface. tag_gps_long1_);} catch (IOException e) {e. printStackTrace ();}

 

 

Question:

Official api:

Public boolean getLatLong (float [] output)

Meaning: Stores the latitude and longpolling value in a float array. The first element is the latitude, and the second element is the longpolling. Returns false if the Exif tags are not available.

This method uses a floating point array to store longitude and latitude information. The specific node to which the data is stored is to be verified. If the data is automatically stored on the TAG_GPS_LATITUDE and tag_gps_long1_nodes, then, the conversion method of the front edge can be saved. If you are interested, you can check it out.


 

 

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.