From 626f6a1a3a6bdbab933d62d593f5279797f4bb0d Mon Sep 17 00:00:00 2001 From: klymp <14829626+kylmp@users.noreply.github.com> Date: Sun, 26 Jul 2026 17:20:54 +0200 Subject: [PATCH] Fix exif info display resolution orientation --- app/src/client/sidebar.ts | 8 ++++---- app/src/gallery/exif.ts | 3 +++ app/tests/assetMetadata.test.ts | 13 +++++++++++++ app/tests/sidebarFileMetadata.test.ts | 11 +++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 app/tests/sidebarFileMetadata.test.ts diff --git a/app/src/client/sidebar.ts b/app/src/client/sidebar.ts index 7e146fc..405736d 100644 --- a/app/src/client/sidebar.ts +++ b/app/src/client/sidebar.ts @@ -383,11 +383,11 @@ function formatDate (iso: string): string { } } -function formatBytes (bytes: number): string { +export function formatBytes (bytes: number): string { if (bytes < 1024) return bytes + ' B' const kb = bytes / 1024 - if (kb < 1024) return kb.toFixed(1) + ' KB' + if (kb < 1024) return kb.toFixed(1) + ' KiB' const mb = kb / 1024 - if (mb < 1024) return mb.toFixed(1) + ' MB' - return (mb / 1024).toFixed(2) + ' GB' + if (mb < 1024) return mb.toFixed(1) + ' MiB' + return (mb / 1024).toFixed(2) + ' GiB' } diff --git a/app/src/gallery/exif.ts b/app/src/gallery/exif.ts index 2ffbb93..8d662d0 100644 --- a/app/src/gallery/exif.ts +++ b/app/src/gallery/exif.ts @@ -62,6 +62,9 @@ const EXIF_RULES: FieldRule[] = [ if (info.exifImageWidth && info.exifImageHeight) { out.width = info.exifImageWidth out.height = info.exifImageHeight + if (info.orientation && ['5', '6', '7', '8'].includes(info.orientation)) { + [out.width, out.height] = [out.height, out.width] + } } } }, diff --git a/app/tests/assetMetadata.test.ts b/app/tests/assetMetadata.test.ts index 690e816..2700c8e 100644 --- a/app/tests/assetMetadata.test.ts +++ b/app/tests/assetMetadata.test.ts @@ -55,6 +55,19 @@ describe('buildAssetMetadata', () => { expect(meta.exif?.city).toBeUndefined() }) + it('reports dimensions in display orientation', () => { + setConfig({ ipp: { showMetadata: { exif: { dimensions: true } } } }) + const photo = asset() + photo.exifInfo!.exifImageWidth = 4000 + photo.exifInfo!.exifImageHeight = 3000 + photo.exifInfo!.orientation = '6' + + expect(buildAssetMetadata(photo, share()).exif).toMatchObject({ + width: 3000, + height: 4000 + }) + }) + it('returns description when a description surface is enabled', () => { setConfig({ ipp: { showMetadata: { description: { sidebar: true } } } }) const meta = buildAssetMetadata(asset(), share()) diff --git a/app/tests/sidebarFileMetadata.test.ts b/app/tests/sidebarFileMetadata.test.ts new file mode 100644 index 0000000..68c7d29 --- /dev/null +++ b/app/tests/sidebarFileMetadata.test.ts @@ -0,0 +1,11 @@ +import { describe, expect, it } from 'vitest' +import { formatBytes } from '../src/client/sidebar' + +describe('sidebar file metadata formatting', () => { + it('uses binary unit labels for binary calculations', () => { + expect(formatBytes(1023)).toBe('1023 B') + expect(formatBytes(1024)).toBe('1.0 KiB') + expect(formatBytes(3_500_000)).toBe('3.3 MiB') + expect(formatBytes(3 * 1024 ** 3)).toBe('3.00 GiB') + }) +})