[O] Format exposure
This commit is contained in:
@@ -13,6 +13,13 @@ import java.util.Base64
|
||||
import java.util.Locale
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
fun formatExposureTime(t: Double): String {
|
||||
return if (t <= 0) t.toString()
|
||||
else if (t < 1.0) "1/${(1.0 / t).roundToInt()}s"
|
||||
else if (t < 10) "%.1fs".format(t)
|
||||
else "%.0fs".format(t)
|
||||
}
|
||||
|
||||
data class ExifResult(val shutterInfo: String, val cameraInfo: String, val dateTime: String, val location: String, val urlName: String, val w: Int, val h: Int) {
|
||||
override fun toString(): String {
|
||||
return "Date/Time: $dateTime\nLocation: $location\nCamera Info: $cameraInfo\nShutter Info: $shutterInfo\nURL Name: $urlName"
|
||||
@@ -24,7 +31,7 @@ suspend fun parseExif(data: ByteArray): ExifResult? {
|
||||
val d = exif.convertToPhotoMetadata()
|
||||
|
||||
return ExifResult(
|
||||
shutterInfo = "${d.focalLength?.roundToInt()}mm f/${d.fNumber} ${d.exposureTime}s ISO-${d.iso}",
|
||||
shutterInfo = "${d.focalLength?.roundToInt()}mm f/${d.fNumber} ${formatExposureTime(d.exposureTime)}s ISO-${d.iso}",
|
||||
// TODO: Un-hardcode this in the future
|
||||
cameraInfo = if (d.cameraModel == "ILCE-6700") "Sony ILCE-6700 + Tamron 18-300 F3.5-6.3" else listOfNotNull(
|
||||
listOfNotNull(d.cameraMake?.lowercase()?.replaceFirstChar { it.titlecase() }, d.cameraModel).ifEmpty { null }?.joinToString(" "),
|
||||
|
||||
Reference in New Issue
Block a user