Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tiles: don't process images <= tile dimensions #1760

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion invenio_rdm_records/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,12 @@ def lock_edit_published_files(service, identity, record=None, draft=None):
Relative paths are resolved against the application instance path.
"""

IIIF_TILES_CONVERTER_PARAMS = {}
IIIF_TILES_CONVERTER_PARAMS = {
"compression": "jpeg",
"Q": 90,
"tile_width": 256,
"tile_height": 256,
}
"""Parameters to be passed to the tiles converter."""

RDM_RECORDS_RESTRICTION_GRACE_PERIOD = timedelta(days=30)
Expand Down
13 changes: 12 additions & 1 deletion invenio_rdm_records/records/processors/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,18 @@ def _can_process(self, draft, record) -> bool:

def _can_process_file(self, file_record, draft, record) -> bool:
"""Checks to determine if to process the record."""
return file_record.file.ext in self.valid_exts
if file_record.file.ext not in self.valid_exts:
return False

iiif_config = current_app.config.get("IIIF_TILES_CONVERTER_PARAMS")
metadata = file_record.metadata or {}

if (metadata.get("height", 0) <= iiif_config.get("tile_width")) or (
metadata.get("width", 0) <= iiif_config.get("tile_height")
):
return False

return True

@contextmanager
def unlocked_bucket(self, files):
Expand Down
Loading