From 2f4397a6558f509012451afc88aac132189062a1 Mon Sep 17 00:00:00 2001 From: TrevorBurgoyne Date: Fri, 21 Aug 2026 17:42:44 -0500 Subject: [PATCH 1/2] add m4d --- imgparse/pixel_pitches.py | 3 +++ tests/test_imgparse.py | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/imgparse/pixel_pitches.py b/imgparse/pixel_pitches.py index d4b7fad..2f7938d 100644 --- a/imgparse/pixel_pitches.py +++ b/imgparse/pixel_pitches.py @@ -35,6 +35,9 @@ "M4E": { 5280: 3.28e-06, # Wide camera (4/3" CMOS, 5280x3956) }, + "M4D": { + 5280: 3.28e-06, # Wide camera (4/3" CMOS, 5280x3956) + }, "FC6360": 3.0e-06, # Phantom 4 Multispectral "FC6310R": 2.41e-06, # Phatom 4 Pro RTK "M3M": 3.28e-06, # Mavic 3 Multispectral diff --git a/tests/test_imgparse.py b/tests/test_imgparse.py index 8dfdf9d..11c0ada 100644 --- a/tests/test_imgparse.py +++ b/tests/test_imgparse.py @@ -113,6 +113,34 @@ def m4e_tele_parser() -> MetadataParser: return parser +@pytest.fixture +def m4d_wide_parser() -> MetadataParser: + parser = MetadataParser(base_path / "M4D_wide.JPG") + parser._exif_data = { + "Image Make": Tag("DJI"), + "Image Model": Tag("M4D"), + "EXIF FocalLength": Tag([Ratio(1229, 100)]), + "EXIF ExifImageWidth": Tag([5280]), + "EXIF ExifImageLength": Tag([3956]), + } + parser._xmp_data = {} + return parser + + +@pytest.fixture +def m4d_tele_parser() -> MetadataParser: + parser = MetadataParser(base_path / "M4D_tele.JPG") + parser._exif_data = { + "Image Make": Tag("DJI"), + "Image Model": Tag("M4D"), + "EXIF FocalLength": Tag([Ratio(1229, 100)]), + "EXIF ExifImageWidth": Tag([8064]), + "EXIF ExifImageLength": Tag([6048]), + } + parser._xmp_data = {} + return parser + + @pytest.fixture def dji_homepoint_parser() -> MetadataParser: return MetadataParser(base_path / "DJI_home_point.jpg") @@ -194,6 +222,18 @@ def test_get_camera_params_m4e_non_wide_unsupported( m4e_tele_parser.pixel_pitch_meters() +def test_get_camera_params_m4d_wide(m4d_wide_parser: MetadataParser) -> None: + assert m4d_wide_parser.pixel_pitch_meters() == 3.28e-06 + assert m4d_wide_parser.focal_length_pixels() == pytest.approx(3746.9512, abs=1e-04) + + +def test_get_camera_params_m4d_non_wide_unsupported( + m4d_tele_parser: MetadataParser, +) -> None: + with pytest.raises(ParsingError): + m4d_tele_parser.pixel_pitch_meters() + + def test_get_camera_params_sentera(sentera_parser: MetadataParser) -> None: focal1 = sentera_parser.focal_length_meters() pitch = sentera_parser.pixel_pitch_meters() From beba04269f4fb095aa53073014541bf772321030 Mon Sep 17 00:00:00 2001 From: TrevorBurgoyne Date: Fri, 21 Aug 2026 17:43:12 -0500 Subject: [PATCH 2/2] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a5f6874..e277ee0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "imgparse" -version = "2.0.13" +version = "2.0.14" description = "Python image-metadata-parser utilities" authors = [] include = [