Skip to content

Commit e0c6975

Browse files
yashlambaptamarit
authored andcommitted
iiif: schema: only return images within size limit in manifest
1 parent c387d84 commit e0c6975

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

invenio_rdm_records/config.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,12 @@ def lock_edit_published_files(service, identity, record=None, draft=None):
597597
Relative paths are resolved against the application instance path.
598598
"""
599599

600-
IIIF_TILES_CONVERTER_PARAMS = {}
600+
IIIF_TILES_CONVERTER_PARAMS = {
601+
"compression": "jpeg",
602+
"Q": 90,
603+
"tile_width": 256,
604+
"tile_height": 256,
605+
}
601606
"""Parameters to be passed to the tiles converter."""
602607

603608
RDM_RECORDS_RESTRICTION_GRACE_PERIOD = timedelta(days=30)

invenio_rdm_records/resources/serializers/iiif/schema.py

+8
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,18 @@ class ListIIIFFilesAttribute(fields.List):
132132

133133
def get_value(self, obj, *args, **kwargs):
134134
"""Return the value for a given key from an object attribute."""
135+
iiif_config = current_app.config.get("IIIF_TILES_CONVERTER_PARAMS")
136+
valid_metadata = (
137+
lambda x: x
138+
and x["height"] > iiif_config["tile_height"]
139+
and x["width"] > iiif_config["tile_width"]
140+
)
141+
135142
return [
136143
f
137144
for f in obj["files"].get("entries", {}).values()
138145
if f["ext"] in current_app.config["RDM_IIIF_MANIFEST_FORMATS"]
146+
and valid_metadata(f["metadata"])
139147
]
140148

141149

0 commit comments

Comments
 (0)