Special exception for non-images

This commit is contained in:
Kovid Goyal 2016-05-09 20:20:40 +05:30
parent 4303db417a
commit bd822c7ff2

View File

@ -15,6 +15,9 @@ from calibre.utils.config_base import tweaks
from calibre.utils.filenames import atomic_rename from calibre.utils.filenames import atomic_rename
imageops, imageops_err = plugins['imageops'] imageops, imageops_err = plugins['imageops']
class NotImage(ValueError):
pass
def get_exe_path(name): def get_exe_path(name):
from calibre.ebooks.pdf.pdftohtml import PDFTOHTML from calibre.ebooks.pdf.pdftohtml import PDFTOHTML
base = os.path.dirname(PDFTOHTML) base = os.path.dirname(PDFTOHTML)
@ -42,7 +45,7 @@ def image_from_data(data):
return data return data
i = QImage() i = QImage()
if not i.loadFromData(data): if not i.loadFromData(data):
raise ValueError('Not a valid image') raise NotImage('Not a valid image')
return i return i
def image_and_format_from_data(data): def image_and_format_from_data(data):