mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-11-10 06:34:11 +01:00
58 lines
1.5 KiB
Python
58 lines
1.5 KiB
Python
|
|
import pytest
|
||
|
|
from PIL import Image
|
||
|
|
from eynollah.cli import (
|
||
|
|
enhancement as enhancement_cli,
|
||
|
|
)
|
||
|
|
from ocrd_modelfactory import page_from_file
|
||
|
|
from ocrd_models.constants import NAMESPACES as NS
|
||
|
|
|
||
|
|
@pytest.mark.parametrize(
|
||
|
|
"options",
|
||
|
|
[
|
||
|
|
[], # defaults
|
||
|
|
["-sos"],
|
||
|
|
], ids=str)
|
||
|
|
def test_run_eynollah_enhancement_filename(
|
||
|
|
tmp_path,
|
||
|
|
resources_dir,
|
||
|
|
run_eynollah_ok_and_check_logs,
|
||
|
|
options,
|
||
|
|
):
|
||
|
|
infile = resources_dir / 'kant_aufklaerung_1784_0020.tif'
|
||
|
|
outfile = tmp_path.joinpath('kant_aufklaerung_1784_0020.png')
|
||
|
|
run_eynollah_ok_and_check_logs(
|
||
|
|
enhancement_cli,
|
||
|
|
[
|
||
|
|
'-i', str(infile),
|
||
|
|
'-o', str(outfile.parent),
|
||
|
|
] + options,
|
||
|
|
[
|
||
|
|
'Image was enhanced',
|
||
|
|
]
|
||
|
|
)
|
||
|
|
with Image.open(infile) as original_img:
|
||
|
|
original_size = original_img.size
|
||
|
|
with Image.open(outfile) as enhanced_img:
|
||
|
|
enhanced_size = enhanced_img.size
|
||
|
|
assert (original_size == enhanced_size) == ("-sos" in options)
|
||
|
|
|
||
|
|
def test_run_eynollah_enhancement_directory(
|
||
|
|
tmp_path,
|
||
|
|
resources_dir,
|
||
|
|
image_resources,
|
||
|
|
run_eynollah_ok_and_check_logs,
|
||
|
|
):
|
||
|
|
outdir = tmp_path
|
||
|
|
run_eynollah_ok_and_check_logs(
|
||
|
|
enhancement_cli,
|
||
|
|
[
|
||
|
|
'-di', str(resources_dir),
|
||
|
|
'-o', str(outdir),
|
||
|
|
],
|
||
|
|
[
|
||
|
|
f'Image {image_resources[0]} was enhanced',
|
||
|
|
f'Image {image_resources[1]} was enhanced',
|
||
|
|
]
|
||
|
|
)
|
||
|
|
assert len(list(outdir.iterdir())) == 2
|