Skip to content
Open
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
8 changes: 5 additions & 3 deletions sorl/thumbnail/engines/pil_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def _get_raw_data(self, image, format_, quality, image_info=None, progressive=Fa
}

# keeps icc_profile
if 'icc_profile' in image_info:
if image_info and 'icc_profile' in image_info:
params['icc_profile'] = image_info['icc_profile']

raw_data = None
Expand All @@ -278,11 +278,13 @@ def _get_raw_data(self, image, format_, quality, image_info=None, progressive=Fa
# Do not save unnecessary exif data for smaller thumbnail size
params.pop('exif', {})
image.save(bf, **params)
raw_data = bf.getvalue()
except OSError:
# Try without optimization.
# Try without optimization and icc_profile.
params.pop('optimize')
if 'icc_profile' in params:
params.pop('icc_profile')
image.save(bf, **params)
else:
raw_data = bf.getvalue()
finally:
bf.close()
Expand Down