Reformat exposure time in exif data.
Exposure time is returned from camera as a string like 1/11. ExifInterface on expects exposure time to be formatted as a string but the string should contain decimal formatted number instead of fraction format.
This commit is contained in:
parent
f1094302c7
commit
009da5a250
|
@ -197,8 +197,12 @@ public class MutableImage {
|
||||||
// to be transformed into Upper camel case format.
|
// to be transformed into Upper camel case format.
|
||||||
String tagName = tag.getTagName().replaceAll(" ", "");
|
String tagName = tag.getTagName().replaceAll(" ", "");
|
||||||
Object object = directory.getObject(tagType);
|
Object object = directory.getObject(tagType);
|
||||||
|
if (tagName.equals(ExifInterface.TAG_EXPOSURE_TIME)) {
|
||||||
|
exif.setAttribute(tagName, convertExposureTimeToDoubleFormat(object.toString()));
|
||||||
|
} else {
|
||||||
exif.setAttribute(tagName, object.toString());
|
exif.setAttribute(tagName, object.toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeLocationExifData(options, exif);
|
writeLocationExifData(options, exif);
|
||||||
|
|
||||||
|
@ -211,6 +215,18 @@ public class MutableImage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reformats exposure time value to match ExifInterface format. Example 1/11 -> 0.0909
|
||||||
|
// Even the value is formatted as double it is returned as a String because exif.setAttribute requires it.
|
||||||
|
private String convertExposureTimeToDoubleFormat(String exposureTime) {
|
||||||
|
if(!exposureTime.contains("/"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
String exposureFractions[]= exposureTime.split("/");
|
||||||
|
double divider = Double.parseDouble(exposureFractions[1]);
|
||||||
|
double exposureTimeAsDouble = 1.0f / divider;
|
||||||
|
return Double.toString(exposureTimeAsDouble);
|
||||||
|
}
|
||||||
|
|
||||||
private void rewriteOrientation(ExifInterface exif) {
|
private void rewriteOrientation(ExifInterface exif) {
|
||||||
exif.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(ExifInterface.ORIENTATION_NORMAL));
|
exif.setAttribute(ExifInterface.TAG_ORIENTATION, String.valueOf(ExifInterface.ORIENTATION_NORMAL));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue