Example usage for android.media ExifInterface TAG_EXPOSURE_TIME

List of usage examples for android.media ExifInterface TAG_EXPOSURE_TIME

Introduction

In this page you can find the example usage for android.media ExifInterface TAG_EXPOSURE_TIME.

Prototype

String TAG_EXPOSURE_TIME

To view the source code for android.media ExifInterface TAG_EXPOSURE_TIME.

Click Source Link

Document

Type is double.

Usage

From source file:Main.java

public static void copyExifData(File srcImgFile, File dstImgFile) throws IOException {
    ExifInterface srcExif = new ExifInterface(srcImgFile.getCanonicalPath());
    ExifInterface dstExif = new ExifInterface(dstImgFile.getCanonicalPath());

    int buildSDKVersion = Build.VERSION.SDK_INT;

    // From API 11
    if (buildSDKVersion >= Build.VERSION_CODES.HONEYCOMB) {
        if (srcExif.getAttribute(ExifInterface.TAG_APERTURE) != null) {
            dstExif.setAttribute(ExifInterface.TAG_APERTURE, srcExif.getAttribute(ExifInterface.TAG_APERTURE));
        }/*from ww  w  .jav  a 2s  .  co  m*/
        if (srcExif.getAttribute(ExifInterface.TAG_EXPOSURE_TIME) != null) {
            dstExif.setAttribute(ExifInterface.TAG_EXPOSURE_TIME,
                    srcExif.getAttribute(ExifInterface.TAG_EXPOSURE_TIME));
        }
        if (srcExif.getAttribute(ExifInterface.TAG_ISO) != null) {
            dstExif.setAttribute(ExifInterface.TAG_ISO, srcExif.getAttribute(ExifInterface.TAG_ISO));
        }
    }

    // From API 9
    if (buildSDKVersion >= Build.VERSION_CODES.GINGERBREAD) {
        if (srcExif.getAttribute(ExifInterface.TAG_GPS_ALTITUDE) != null) {
            dstExif.setAttribute(ExifInterface.TAG_GPS_ALTITUDE,
                    srcExif.getAttribute(ExifInterface.TAG_GPS_ALTITUDE));
        }
        if (srcExif.getAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF) != null) {
            dstExif.setAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF,
                    srcExif.getAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF));
        }
    }

    // From API 8
    if (buildSDKVersion >= Build.VERSION_CODES.FROYO) {
        if (srcExif.getAttribute(ExifInterface.TAG_FOCAL_LENGTH) != null) {
            dstExif.setAttribute(ExifInterface.TAG_FOCAL_LENGTH,
                    srcExif.getAttribute(ExifInterface.TAG_FOCAL_LENGTH));
        }
        if (srcExif.getAttribute(ExifInterface.TAG_GPS_DATESTAMP) != null) {
            dstExif.setAttribute(ExifInterface.TAG_GPS_DATESTAMP,
                    srcExif.getAttribute(ExifInterface.TAG_GPS_DATESTAMP));
        }
        if (srcExif.getAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD) != null) {
            dstExif.setAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD,
                    srcExif.getAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD));
        }
        if (srcExif.getAttribute(ExifInterface.TAG_GPS_TIMESTAMP) != null) {
            dstExif.setAttribute(ExifInterface.TAG_GPS_TIMESTAMP,
                    srcExif.getAttribute(ExifInterface.TAG_GPS_TIMESTAMP));
        }
    }

    if (srcExif.getAttribute(ExifInterface.TAG_DATETIME) != null) {
        dstExif.setAttribute(ExifInterface.TAG_DATETIME, srcExif.getAttribute(ExifInterface.TAG_DATETIME));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_FLASH) != null) {
        dstExif.setAttribute(ExifInterface.TAG_FLASH, srcExif.getAttribute(ExifInterface.TAG_FLASH));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_GPS_LATITUDE) != null) {
        dstExif.setAttribute(ExifInterface.TAG_GPS_LATITUDE,
                srcExif.getAttribute(ExifInterface.TAG_GPS_LATITUDE));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF) != null) {
        dstExif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF,
                srcExif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE) != null) {
        dstExif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE,
                srcExif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF) != null) {
        dstExif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF,
                srcExif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH) != null) {
        dstExif.setAttribute(ExifInterface.TAG_IMAGE_LENGTH,
                srcExif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH) != null) {
        dstExif.setAttribute(ExifInterface.TAG_IMAGE_WIDTH,
                srcExif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_MAKE) != null) {
        dstExif.setAttribute(ExifInterface.TAG_MAKE, srcExif.getAttribute(ExifInterface.TAG_MAKE));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_MODEL) != null) {
        dstExif.setAttribute(ExifInterface.TAG_MODEL, srcExif.getAttribute(ExifInterface.TAG_MODEL));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_ORIENTATION) != null) {
        dstExif.setAttribute(ExifInterface.TAG_ORIENTATION,
                srcExif.getAttribute(ExifInterface.TAG_ORIENTATION));
    }
    if (srcExif.getAttribute(ExifInterface.TAG_WHITE_BALANCE) != null) {
        dstExif.setAttribute(ExifInterface.TAG_WHITE_BALANCE,
                srcExif.getAttribute(ExifInterface.TAG_WHITE_BALANCE));
    }

    dstExif.saveAttributes();
}

From source file:freed.viewer.screenslide.ScreenSlideFragment.java

private void processExif(final File file) {
    FreeDPool.Execute(new Runnable() {
        @Override/*from  w ww.  j av a 2s  .co  m*/
        public void run() {
            try {
                final ExifInterface exifInterface = new ExifInterface(file.getAbsolutePath());
                iso.post(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            shutter.setText("S:" + exifInterface.getAttribute(ExifInterface.TAG_EXPOSURE_TIME));
                        } catch (NullPointerException e) {
                            shutter.setVisibility(View.GONE);
                        }
                        try {
                            fnumber.setText("f~:" + exifInterface.getAttribute(ExifInterface.TAG_F_NUMBER));
                        } catch (NullPointerException e) {
                            fnumber.setVisibility(View.GONE);
                        }
                        try {
                            focal.setText("A:" + exifInterface.getAttribute(ExifInterface.TAG_APERTURE_VALUE));
                        } catch (NullPointerException e) {
                            focal.setVisibility(View.GONE);
                        }
                        try {
                            iso.setText(
                                    "ISO:" + exifInterface.getAttribute(ExifInterface.TAG_ISO_SPEED_RATINGS));
                        } catch (NullPointerException e) {
                            iso.setVisibility(View.GONE);
                        }
                    }
                });

            } catch (NullPointerException | IOException ex) {
                Log.d(TAG, "Failed to read Exif");
            }
        }
    });
}