From 372f7259cc7a53d211a4ac072d91f335eeb41bf0 Mon Sep 17 00:00:00 2001 From: Markus Barth Date: Fri, 27 Sep 2024 09:48:42 +0200 Subject: [PATCH 1/4] Added space after %U in imagemagick identify format prameter. --- src/ocrd_models/ocrd_exif.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ocrd_models/ocrd_exif.py b/src/ocrd_models/ocrd_exif.py index 406e60a85..b5701771a 100644 --- a/src/ocrd_models/ocrd_exif.py +++ b/src/ocrd_models/ocrd_exif.py @@ -48,11 +48,11 @@ def run_identify(self, img): for prop in ['compression', 'photometric_interpretation']: setattr(self, prop, img.info[prop] if prop in img.info else None) if img.filename: - ret = run(['identify', '-format', r'%[resolution.x] %[resolution.y] %U', img.filename], check=False, stderr=PIPE, stdout=PIPE) + ret = run(['identify', '-format', r'%[resolution.x] %[resolution.y] %U ', img.filename], check=False, stderr=PIPE, stdout=PIPE) else: with BytesIO() as bio: img.save(bio, format=img.format) - ret = run(['identify', '-format', r'%[resolution.x] %[resolution.y] %U', '/dev/stdin'], check=False, stderr=PIPE, stdout=PIPE, input=bio.getvalue()) + ret = run(['identify', '-format', r'%[resolution.x] %[resolution.y] %U ', '/dev/stdin'], check=False, stderr=PIPE, stdout=PIPE, input=bio.getvalue()) if ret.returncode: stderr = ret.stderr.decode('utf-8') if 'no decode delegate for this image format' in stderr: From 44deb80434dbcf40289f7ce451e416f5f021a54d Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Fri, 27 Sep 2024 20:11:36 +0200 Subject: [PATCH 2/4] ocrd_exif: add multi-frame TIFF example --- tests/model/test_exif.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/model/test_exif.py b/tests/model/test_exif.py index f6771fb8e..077247521 100644 --- a/tests/model/test_exif.py +++ b/tests/model/test_exif.py @@ -24,7 +24,10 @@ ('leptonica_samples/data/OCR-D-IMG/OCR-D-IMG_1555_007.jpg', 944, 1472, 1, 1, 1, 'inches', 'RGB', None), ('kant_aufklaerung_1784-jp2/data/OCR-D-IMG/INPUT_0020.jp2', - 1457, 2084, 1, 1, 1, 'inches', 'RGB', None) + 1457, 2084, 1, 1, 1, 'inches', 'RGB', None), + # tolerate multi-frame TIFF: + ('gutachten/data/IMG/IMG_1.tif', + 2088, 2634, 300, 300, 300, 'inches', 'RGB', 'raw') ]) def test_ocrd_exif(path, width, height, xResolution, yResolution, resolution, resolutionUnit, photometricInterpretation, compression): """Check EXIF attributes for different input formats From 4d25fcfa63c98dec7a66fcf5fdf7c959e6bb2713 Mon Sep 17 00:00:00 2001 From: kba Date: Mon, 30 Sep 2024 18:11:18 +0200 Subject: [PATCH 3/4] update assets --- repo/assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo/assets b/repo/assets index 05568aaa2..ca108faf0 160000 --- a/repo/assets +++ b/repo/assets @@ -1 +1 @@ -Subproject commit 05568aaa2dc20678bf87ffec77f3baf2924d7c24 +Subproject commit ca108faf0e95cc823a9e84cd0a1602282ae006b1 From bdfb41080a8291f3f87280669c684f8a191cb7d5 Mon Sep 17 00:00:00 2001 From: kba Date: Mon, 30 Sep 2024 18:17:03 +0200 Subject: [PATCH 4/4] test_exif: add example provided by @mexthecat --- tests/model/test_exif.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/model/test_exif.py b/tests/model/test_exif.py index 077247521..18c5e4c46 100644 --- a/tests/model/test_exif.py +++ b/tests/model/test_exif.py @@ -27,7 +27,10 @@ 1457, 2084, 1, 1, 1, 'inches', 'RGB', None), # tolerate multi-frame TIFF: ('gutachten/data/IMG/IMG_1.tif', - 2088, 2634, 300, 300, 300, 'inches', 'RGB', 'raw') + 2088, 2634, 300, 300, 300, 'inches', 'RGB', 'raw'), + # multi-frame TIFF with metric pixel density (is actually YCBCR not RGB but Pillow thinks otherwise...) + ('indian-ferns/data/OCR-D-IMG/0004.tif', + 2626, 3620, 28, 28, 28, 'cm', 'RGB', 'jpeg'), ]) def test_ocrd_exif(path, width, height, xResolution, yResolution, resolution, resolutionUnit, photometricInterpretation, compression): """Check EXIF attributes for different input formats