Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(metadata-json):fix-degree-minute-XMP-GPS-issue

Aswin Asoka8c184452d7a
diff --git a/desktop/changes/apple-photos-xmp-sidecars.md b/desktop/changes/apple-photos-xmp-sidecars.md
new file mode 100644
index 0000000000..9eecb0caff
--- /dev/null
+++ b/desktop/changes/apple-photos-xmp-sidecars.md
@@ -0,0 +1 @@
+- Added support for reading Apple Photos XMP sidecar files during folder and ZIP imports, preserving dates, locations, and captions.
diff --git a/web/apps/photos/src/components/TakeoutOptions.tsx b/web/apps/photos/src/components/TakeoutOptions.tsx
index 114aad68ee..f1aba2a14d 100644
--- a/web/apps/photos/src/components/TakeoutOptions.tsx
+++ b/web/apps/photos/src/components/TakeoutOptions.tsx
@@ -30,9 +30,10 @@ const optionsTitleSx = {
const stepSx = {
color: "text.muted",
- fontSize: "14px",
- fontWeight: 500,
- lineHeight: "20px",
+ fontSize: "13px",
+ fontWeight: 400,
+ lineHeight: "18px",
+ opacity: 0.7,
};
interface TakeoutOptionsProps {
@@ -114,7 +115,7 @@ export function TakeoutOptions({
<Stack sx={{ gap: "20px" }}>
{provider == "apple" && (
- <Stack sx={{ gap: "4px" }}>
+ <Stack sx={{ gap: "6px" }}>
<Typography sx={stepSx}>
{t("apple_export_step_1")}
</Typography>
diff --git a/web/apps/photos/tests/upload.test.ts b/web/apps/photos/tests/upload.test.ts
index 5856a10096..6d267dc89f 100644
--- a/web/apps/photos/tests/upload.test.ts
+++ b/web/apps/photos/tests/upload.test.ts
@@ -174,6 +174,8 @@ describe("Apple Photos XMP sidecars", () => {
test.each([
["12.97236N", "77.59457E", 12.97236, 77.59457],
["33.8688S", "151.2093W", -33.8688, -151.2093],
+ ["37,46.5N", "122,25W", 37.775, -(122 + 25 / 60)],
+ ["33,52.128S", "151,12.558E", -(33 + 52.128 / 60), 151 + 12.558 / 60],
])("parses GPS coordinates %s, %s", (lat, long, latitude, longitude) => {
expect(
parseXMPSidecarTags({
diff --git a/web/packages/gallery/components/upload/DefaultOptions.tsx b/web/packages/gallery/components/upload/DefaultOptions.tsx
index 836f137120..afa8bb819f 100644
--- a/web/packages/gallery/components/upload/DefaultOptions.tsx
+++ b/web/packages/gallery/components/upload/DefaultOptions.tsx
@@ -141,46 +141,48 @@ function ImportOptions({
onSelectFolder,
}: ImportOptionsProps): React.JSX.Element {
return (
- <Stack sx={{ gap: "20px" }}>
- <Stack
- direction="row"
- sx={{
- gap: "10px",
- [uploadSheetMediaQuery]: { flexWrap: "wrap" },
- }}
- >
- <ImportProviderButton
- icon={
- <HugeiconsIcon
- icon={Album02Icon}
- size={22}
- color="var(--mui-palette-text-muted)"
- />
- }
- label={t("google_photos")}
- onClick={onSelectGooglePhotos}
- />
- <ImportProviderButton
- icon={
- <AppleIcon sx={{ color: "text.muted", fontSize: 22 }} />
- }
- label={t("apple_photos")}
- onClick={onSelectApplePhotos}
- />
- <ImportProviderButton
- icon={
- <HugeiconsIcon
- icon={Folder01Icon}
- size={22}
- color="var(--mui-palette-text-muted)"
- />
- }
- label={t("folder")}
- pending={isFolderSelectionPending}
- onClick={onSelectFolder}
- />
- </Stack>
- <DragAndDropHint />
+ <Stack sx={{ gap: "24px" }}>
+ <ImportSection title={t("import_from")}>
+ <Stack direction="row" sx={{ gap: "10px" }}>
+ <ImportProviderButton
+ icon={
+ <HugeiconsIcon
+ icon={Album02Icon}
+ size={22}
+ color="var(--mui-palette-text-muted)"
+ />
+ }
+ label={t("google_photos")}
+ onClick={onSelectGooglePhotos}
+ />
+ <ImportProviderButton
+ icon={
+ <AppleIcon
+ sx={{ color: "text.muted", fontSize: 22 }}
+ />
+ }
+ label={t("apple_photos")}
+ onClick={onSelectApplePhotos}
+ />
+ </Stack>
+ </ImportSection>
+ <ImportSection title={t("upload_from")}>
+ <Stack direction="row">
+ <ImportProviderButton
+ icon={
+ <HugeiconsIcon
+ icon={Folder01Icon}
+ size={22}
+ color="var(--mui-palette-text-muted)"
+ />
+ }
+ label={t("folder")}
+ pending={isFolderSelectionPending}
+ onClick={onSelectFolder}
+ />
+ </Stack>
+ <DragAndDropHint />
+ </ImportSection>
<ImportHelp />
</Stack>
);
diff --git a/web/packages/gallery/services/upload/metadata-json.ts b/web/packages/gallery/services/upload/metadata-json.ts
index cb9c6838e1..7000f4b57f 100644
--- a/web/packages/gallery/services/upload/metadata-json.ts
+++ b/web/packages/gallery/services/upload/metadata-json.ts
@@ -123,11 +123,13 @@ export const parseXMPSidecarTags = (
): ParsedMetadataJSON | undefined => {
const { creationDate, description } = parseExif(tags);
const parseCoordinate = (value: string | undefined) => {
- const match = /^(\d+(?:\.\d+)?)([NSEW])$/.exec(value ?? "");
+ const match = /^(\d+(?:\.\d+)?)(?:,(\d+(?:\.\d+)?))?([NSEW])$/.exec(
+ value ?? "",
+ );
if (!match) return undefined;
- const coordinate = Number(match[1]);
- return match[2] == "S" || match[2] == "W" ? -coordinate : coordinate;
+ const coordinate = Number(match[1]) + Number(match[2] ?? 0) / 60;
+ return match[3] == "S" || match[3] == "W" ? -coordinate : coordinate;
};
const latitude = parseCoordinate(tags.xmp?.GPSLatitude?.description);
const longitude = parseCoordinate(tags.xmp?.GPSLongitude?.description);