Skip to content

Commit

Permalink
Merge branch 'mexthecat-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Sep 30, 2024
2 parents f808b72 + bdfb410 commit c744dc8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ocrd_models/ocrd_exif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion tests/model/test_exif.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
('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'),
# 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
Expand Down

0 comments on commit c744dc8

Please sign in to comment.