Unverified Commit 92ccd56f authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

create custom file extension and mimetype for posters

parent c8b9a66c
Pipeline #22115 passed with stages
in 1 minute and 40 seconds
......@@ -81,15 +81,30 @@ def _extract_thumbnail_values(msg, _access_status) -> dict:
"""
Extract information on thumbnail from JSON object
"""
return_values = {'mimetype': 'image/jp2', 'type': 'image', 'access': 'public', 'proto': 'file',
'sig': '{}-poster'.format(msg['@id'].split('/')[-2]),
'uri': 'file:///data/{}-poster.jp2'.format(msg['@id'].split('/')[-2])}
return_values = {'type': 'image', 'access': 'public', 'proto': 'file',
'sig': '{}-poster'.format(msg['@id'].split('/')[-2])}
if 'height' in msg:
height = _normalize_dimension(msg['height'])
return_values['height'] = height
if 'width' in msg:
width = _normalize_dimension(msg['width'])
return_values['width'] = width
if 'hasMimeType' in msg:
return_values['mimetype'] = msg['hasMimeType']
if return_values['mimetype'] == 'image/jpeg':
file_extension = 'jpg'
elif return_values['mimetype'] == 'image/png':
file_extension = 'png'
elif return_values['mimetype'] == 'image/jp2':
file_extension = 'jp2'
else:
file_extension = ''
logging.warning('No valid mimetype found!')
else:
file_extension = ''
logging.warning('No valid mimetype found!')
return_values['uri'] = 'file:///data/{}-poster.{}'.\
format(msg['@id'].split('/')[-2], file_extension)
return return_values
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment