mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Conversion: Handle corrupted JPEG files that have valid headers but invalid data. Fixes #1622416 [Private bug](https://bugs.launchpad.net/calibre/+bug/1622416)
This commit is contained in:
parent
b13b1ea5aa
commit
b0f808f2a0
@ -65,12 +65,16 @@ class RescaleImages(object):
|
||||
new_height = max(1, new_height)
|
||||
self.log('Rescaling image from %dx%d to %dx%d'%(
|
||||
width, height, new_width, new_height), item.href)
|
||||
img = img.resize((new_width, new_height))
|
||||
try:
|
||||
img = img.resize((new_width, new_height))
|
||||
except Exception:
|
||||
self.log.exception('Failed to rescale image: %s' % item.href)
|
||||
continue
|
||||
buf = BytesIO()
|
||||
try:
|
||||
img.save(buf, ext)
|
||||
except Exception:
|
||||
self.log.exception('Failed to rescale image')
|
||||
self.log.exception('Failed to rescale image: %s' % item.href)
|
||||
else:
|
||||
item.data = buf.getvalue()
|
||||
item.unload_data_from_memory()
|
||||
|
Loading…
x
Reference in New Issue
Block a user