Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Format EXIF values in file details

AmanRajSinghMourya4a8f96e0d283
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
index 2d6fdc8286..b5072840ed 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
@@ -401,15 +401,15 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
void _generateExifForDetails(Map<String, IfdTag> exif) {
if (exif["EXIF FocalLength"] != null) {
- _exifData["focalLength"] =
- (exif["EXIF FocalLength"]!.values.toList()[0] as Ratio).numerator /
- (exif["EXIF FocalLength"]!.values.toList()[0] as Ratio).denominator;
+ _exifData["focalLength"] = _formatExifRatio(
+ exif["EXIF FocalLength"]!.values.toList()[0] as Ratio,
+ );
}
if (exif["EXIF FNumber"] != null) {
- _exifData["fNumber"] =
- (exif["EXIF FNumber"]!.values.toList()[0] as Ratio).numerator /
- (exif["EXIF FNumber"]!.values.toList()[0] as Ratio).denominator;
+ _exifData["fNumber"] = _formatExifRatio(
+ exif["EXIF FNumber"]!.values.toList()[0] as Ratio,
+ );
}
final imageWidth = _firstPositiveDimensionTag(exif, const [
"EXIF ExifImageWidth",
@@ -444,6 +444,14 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
}
}
+ String _formatExifRatio(Ratio ratio) {
+ if (ratio.denominator == 0) {
+ return ratio.toString();
+ }
+ final value = ratio.numerator / ratio.denominator;
+ return value.toStringAsFixed(2).replaceFirst(RegExp(r"\.?0+$"), "");
+ }
+
/// Formats exposure time from EXIF data into a human-readable string.
///
/// For shutter speeds >= 1 second, displays as decimal with 's' suffix (e.g., "1.3s")