mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-03-20 00:17:53 -04:00
More useful error message when loading image from data fails
This commit is contained in:
parent
ce7e0eed2f
commit
bdb6839a76
@ -124,7 +124,14 @@ def image_from_data(data):
|
||||
q = what(None, data)
|
||||
if q == 'jxr':
|
||||
return load_jxr_data(data)
|
||||
raise NotImage(f'Not a valid image (detected type: {q})')
|
||||
ba = QByteArray(data)
|
||||
buf = QBuffer(ba)
|
||||
buf.open(QIODevice.OpenModeFlag.ReadOnly)
|
||||
r = QImageReader(buf)
|
||||
i = r.read()
|
||||
buf.close()
|
||||
if i.isNull():
|
||||
raise NotImage(f'Not a valid image (detected type: {q}). Error: {r.errorString()}')
|
||||
return i
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user