From b1db1ec40935004c7bc0400678a2c6a29fcb70f0 Mon Sep 17 00:00:00 2001 From: "jack.lewis" Date: Fri, 19 Jan 2024 11:21:47 +0000 Subject: [PATCH] initial commit adding ability to only generate a jp2 --- app/jp2/convert.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/jp2/convert.py b/app/jp2/convert.py index 5a6c583..3ea6b9b 100644 --- a/app/jp2/convert.py +++ b/app/jp2/convert.py @@ -89,6 +89,20 @@ def _ingest_image(source_path: pathlib.Path, dest_path: pathlib.Path, optimisati return dest_path, image_info +def _image_only_operation(source_path: pathlib.Path, + dest_path: pathlib.Path, + kakadu_optimisation: str = 'kdu_med', + **kwargs) -> dict: + ingested_path, image_info = _ingest_image( + source_path, dest_path, kakadu_optimisation) + + return { + 'jp2': str(ingested_path), + 'height': image_info.get('height'), + 'width': image_info.get('width'), + } + + def _derivatives_operation(source_path: pathlib.Path, thumbnail_dir: pathlib.Path, # TODO: shouldn't need to provide thumbnail dir thumbnail_sizes: [int], **kwargs) -> dict: @@ -132,7 +146,8 @@ def process(**kwargs) -> dict: OPERATIONS = { 'ingest': _ingest_operation, - 'derivatives-only': _derivatives_operation + 'derivatives-only': _derivatives_operation, + 'image-only': _image_only_operation } op_func = OPERATIONS.get(kwargs.pop('operation', 'error'), _error) result = op_func(**kwargs)