This commit is contained in:
Kovid Goyal 2008-04-01 19:59:04 +00:00
parent e48dcbe7c2
commit 46a827567a

View File

@ -1724,6 +1724,7 @@ def process_file(path, options, logger=None):
width, height = pwidth, int(corrf*height) width, height = pwidth, int(corrf*height)
scaled, width, height = fit_image(width, height, pwidth, pheight) scaled, width, height = fit_image(width, height, pwidth, pheight)
try:
cim = im.resize((width, height), PILImage.BICUBIC).convert('RGB') if \ cim = im.resize((width, height), PILImage.BICUBIC).convert('RGB') if \
scaled else im scaled else im
cf = PersistentTemporaryFile(prefix=__appname__+"_", suffix=".jpg") cf = PersistentTemporaryFile(prefix=__appname__+"_", suffix=".jpg")
@ -1736,6 +1737,9 @@ def process_file(path, options, logger=None):
tf.close() tf.close()
tim.save(tf.name) tim.save(tf.name)
tpath = tf.name tpath = tf.name
except IOError, err: # PIL sometimes fails, for example on interlaced PNG files
logger.warn(_('Could not read cover image: %s'), err)
options.cover = None
else: else:
raise ConversionError, _('Cannot read from: %s')% (options.cover,) raise ConversionError, _('Cannot read from: %s')% (options.cover,)