Skip to content

Commit

Permalink
added deletion of iiif files
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardKoschicek committed Oct 6, 2023
1 parent 4872e3f commit 4a833ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions openatlas/display/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,14 +767,17 @@ def check_iiif_file_exist(id_: int) -> bool:
return (Path(app.config['IIIF']['path']) / f'{id_}.tiff').is_file()


def get_iiif_file_path(id_: int) -> Path:
return Path(app.config['IIIF']['path']) / f'{id_}.tiff'


def convert_image_to_iiif(id_: int) -> None:
path = Path(app.config['IIIF']['path']) / str(id_)
compression = app.config['IIIF']['compression'] \
if app.config['IIIF']['compression'] in ['deflate', 'jpeg'] \
else 'deflate'
vips = "vips" if os.name == 'posix' else "vips.exe"
command = \
(f"{vips} tiffsave {get_file_path(id_)} {path}.tiff "
(f"{vips} tiffsave {get_file_path(id_)} {get_iiif_file_path} "
f"--tile --pyramid --compression {compression} "
f"--premultiply --tile-width 128 --tile-height 128")
try:
Expand Down
5 changes: 4 additions & 1 deletion openatlas/views/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from openatlas.display.image_processing import resize_image
from openatlas.display.util import (
button, get_base_table_data, get_file_path, is_authorized, link,
required_group)
required_group, get_iiif_file_path, check_iiif_file_exist)
from openatlas.forms.base_manager import BaseManager
from openatlas.forms.form import get_manager
from openatlas.forms.util import was_modified
Expand Down Expand Up @@ -331,3 +331,6 @@ def delete_files(id_: int) -> None:
path.unlink()
for resized_path in app.config['RESIZED_IMAGES'].glob(f'**/{id_}.*'):
resized_path.unlink()
if app.config['IIIF']['activate'] and check_iiif_file_exist(id_):
if path := get_iiif_file_path(id_):
path.unlink()

0 comments on commit 4a833ca

Please sign in to comment.