BUG:Google Takeout photos with duplicate or long names lose their date and location
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
Hướng nghiên cứu
Bắt đầu với backend/app/utils/takeout_sidecar.py và theo dõi cách takeout_sidecar_read ghép tên ảnh với các tệp sidecar. Dùng bốn trường hợp tên tệp trong tập lệnh tái hiện của issue để bổ sung các kiểm thử hồi quy cho tên trùng lặp và tên JSON bị rút ngắn. Hoàn tất khi tất cả các trường hợp trả về ngày ban đầu và tọa độ GPS.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I noticed that PictoPy fails to read the JSON metadata for some photos imported from Google Takeout.
This happens mainly when a photo has a duplicate name or a long filename.
For example, when Google Takeout renames a duplicate photo, the names can look like this:
Photo: IMG_0002(1).jpg
JSON: IMG_0002.jpg(1).json
Another format is:
Photo: IMG_0003(1).jpg
JSON: IMG_0003.jpg.supplemental-metadata(1).json
The same problem happens with long filenames because Google Takeout can shorten the JSON filename.
PictoPy currently looks for a JSON filename starting with the full image name, so it misses these files.
As a result, the photo's original date and GPS location are not read correctly.
Where the problem is
In backend/app/utils/takeout_sidecar.py:
directory, basename = os.path.split(image_path)
prefix = basename + "."
for name in _sidecar_names(directory or "."):
if not name.startswith(prefix):
continue
The comment above this code mentions handling .supplemental-metadata(1).json, but the check still fails when the image itself has (1) in its filename.
Steps to reproduce
Save this as takeout_names.py:
import json, os, sys, tempfile
sys.path.insert(0, sys.argv[1])
from app.utils.takeout_sidecar import takeout_sidecar_read
d = tempfile.mkdtemp()
def make(image, sidecar, ts):
open(os.path.join(d, image), "wb").close()
with open(os.path.join(d, sidecar), "w") as f:
json.dump({
"title": image,
"photoTakenTime": {"timestamp": str(ts)},
"geoData": {
"latitude": 48.85,
"longitude": 2.35
}
}, f)
long_name = "PXL_20230615_101010123.PORTRAIT.ORIGINAL_long_name.jpg"
cases = [
("normal", "IMG_0001.jpg",
"IMG_0001.jpg.supplemental-metadata.json", 1600000000),
("duplicate, old style", "IMG_0002(1).jpg",
"IMG_0002.jpg(1).json", 1600000100),
("duplicate, new style", "IMG_0003(1).jpg",
"IMG_0003.jpg.supplemental-metadata(1).json", 1600000200),
("long name, truncated", long_name,
long_name[:46] + ".json", 1600000300),
]
for label, image, sidecar, ts in cases:
make(image, sidecar, ts)
for label, image, sidecar, ts in cases:
print(f"{label:22} -> {takeout_sidecar_read(os.path.join(d, image))}")
Run it using:
python takeout_names.py /path/to/PictoPy/backend
Output
normal -> ('2020:09:13 17:56:40', 48.85, 2.35)
duplicate, old style -> (None, None, None)
duplicate, new style -> (None, None, None)
long name, truncated -> (None, None, None)
The normal filename works, but the other three fail to return the date and location.
Expected behavior
PictoPy should be able to find these JSON files even when Google Takeout changes or shortens their names.
I also found that GooglePhotosTakeoutHelper handles similar naming cases.
I'd like to work on this issue and add tests for it if the maintainers agree.
- Ngôn ngữ chính
- Python
- Star
- 322
- Fork
- 793
- Merge trung bình
- 6 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AOSSIE-Org/PictoPy
-
bug enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
AOSSIE-Org/PictoPy#1802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
BUG: XMP metadata export permanently overwrites file modification timestamp (mtime), destroying photo datesCó thể đã có người làm @swastiksharma45 đã nhận 2 ngày trước. Đang mởbug enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
AOSSIE-Org/PictoPy#1788 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
AOSSIE-Org/PictoPy#1786 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
BUG: Semantic search sees portrait phone photos sideways (SigLIP ignores EXIF orientation)Có thể đã có người làm @omkar-suryavanshi đã nhận 3 ngày trước. Đang mởbug enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
AOSSIE-Org/PictoPy#1780 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
BUG: Share password loses leading/trailing spaces so the password you set doesn't workCó thể đã có người làm @ManyaJain111 đã nhận 2 ngày trước. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
AOSSIE-Org/PictoPy#1779 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của AOSSIE-Org/PictoPy
Issue tương tự
-
Container fails to start when GitHub Releases is unavailable: uv run re-downloads the tvl wheelĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
trezor/trezor-user-env#421 ·
-
Support new version of pythonĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 91/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
tangentcode/tangentswarm#167 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày