Skip to content

Commit 01f5c7e

Browse files
ranmanclaude
andcommitted
Add EXIF fields to Parquet export
The _flatten_record() function was missing the 12 new EXIF metadata fields, so parquet exports would silently drop camera/lens/exposure data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 02a29f2 commit 01f5c7e

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/imgeda/io/parquet_io.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ def _flatten_record(rec: ImageRecord) -> dict[str, object]:
1818
"color_mode": rec.color_mode,
1919
"num_channels": rec.num_channels,
2020
"aspect_ratio": rec.aspect_ratio,
21+
"camera_make": rec.camera_make or "",
22+
"camera_model": rec.camera_model or "",
23+
"lens_model": rec.lens_model or "",
24+
"focal_length_mm": rec.focal_length_mm if rec.focal_length_mm is not None else 0.0,
25+
"focal_length_35mm": rec.focal_length_35mm if rec.focal_length_35mm is not None else 0,
26+
"iso_speed": rec.iso_speed if rec.iso_speed is not None else 0,
27+
"f_number": rec.f_number if rec.f_number is not None else 0.0,
28+
"exposure_time_sec": (
29+
rec.exposure_time_sec if rec.exposure_time_sec is not None else 0.0
30+
),
31+
"datetime_original": rec.datetime_original or "",
32+
"orientation_tag": rec.orientation_tag if rec.orientation_tag is not None else 0,
33+
"has_gps_data": rec.has_gps_data,
34+
"distortion_risk": rec.distortion_risk or "",
2135
"phash": rec.phash or "",
2236
"dhash": rec.dhash or "",
2337
"is_corrupt": rec.is_corrupt,

tests/test_export.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def sample_records(self) -> list[ImageRecord]:
2323
color_mode="RGB",
2424
num_channels=3,
2525
aspect_ratio=1.3333,
26+
camera_make="Canon" if i % 2 == 0 else None,
27+
focal_length_35mm=14 if i == 0 else 50,
28+
distortion_risk="high" if i == 0 else "low",
2629
pixel_stats=PixelStats(
2730
mean_r=120.0 + i,
2831
mean_g=130.0 + i,
@@ -61,12 +64,21 @@ def test_export_and_read_back(self, sample_records: list[ImageRecord], tmp_path:
6164
assert "pixel_stats.mean_r" in col_names
6265
assert "corner_stats.delta" in col_names
6366
assert "is_corrupt" in col_names
67+
assert "camera_make" in col_names
68+
assert "focal_length_35mm" in col_names
69+
assert "distortion_risk" in col_names
6470

6571
# Verify data
6672
paths = table.column("path").to_pylist()
6773
assert paths[0] == "/img_0.jpg"
6874
assert paths[19] == "/img_19.jpg"
6975

76+
# Verify EXIF data in parquet
77+
assert table.column("camera_make").to_pylist()[0] == "Canon"
78+
assert table.column("camera_make").to_pylist()[1] == "" # None → ""
79+
assert table.column("focal_length_35mm").to_pylist()[0] == 14
80+
assert table.column("distortion_risk").to_pylist()[0] == "high"
81+
7082
def test_export_empty_records(self, tmp_path: Path) -> None:
7183
pytest.importorskip("pyarrow")
7284
from imgeda.io.parquet_io import records_to_parquet

0 commit comments

Comments
 (0)