Skip to content

Commit

Permalink
Upload image thumbnail only if get_dimensions() succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarahui committed May 10, 2024
1 parent b7a223b commit 9f7be23
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions content_harvester/by_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ def harvest_record_content(
content_s3_filepath = None
dimensions = None
if downloaded_md5 and thumbnail.src_mime_type in ['image/jpeg', 'image/png']:
content_s3_filepath = upload_content(
thumbnail.tmp_filepath,
f"thumbnails/{collection_id}/{downloaded_md5}"
)
try:
dimensions = get_dimensions(
thumbnail.tmp_filepath, record['calisphere-id'])
Expand All @@ -120,7 +116,11 @@ def harvest_record_content(
f"Error getting dimensions for {record['calisphere-id']}: "
f"{e}, continuing..."
)

else:
content_s3_filepath = upload_content(
thumbnail.tmp_filepath,
f"thumbnails/{collection_id}/{downloaded_md5}"
)
elif downloaded_md5 and thumbnail.src_mime_type == 'application/pdf':
derivative_filepath = derivatives.pdf_to_thumb(thumbnail.tmp_filepath)
if derivative_filepath:
Expand Down

0 comments on commit 9f7be23

Please sign in to comment.