This commit is contained in:
Kovid Goyal 2010-01-22 13:29:44 -07:00
parent ba693e77a4
commit 8e67557674

View File

@ -6,7 +6,7 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag,
from calibre.customize import CatalogPlugin from calibre.customize import CatalogPlugin
from calibre.ptempfile import PersistentTemporaryDirectory from calibre.ptempfile import PersistentTemporaryDirectory
from calibre.customize.conversion import OptionRecommendation, DummyReporter from calibre.customize.conversion import OptionRecommendation, DummyReporter
from calibre import filesystem_encoding
FIELDS = ['all', 'author_sort', 'authors', 'comments', FIELDS = ['all', 'author_sort', 'authors', 'comments',
'cover', 'formats', 'id', 'isbn', 'pubdate', 'publisher', 'rating', 'cover', 'formats', 'id', 'isbn', 'pubdate', 'publisher', 'rating',
@ -377,7 +377,10 @@ class EPUB_MOBI(CatalogPlugin):
self.text = ''.join(result) self.text = ''.join(result)
else: else:
number = int(self.number) try:
number = int(self.number)
except:
return
if number > 1000000: if number > 1000000:
self.text = "%d out of range" % number self.text = "%d out of range" % number
@ -2453,26 +2456,28 @@ class EPUB_MOBI(CatalogPlugin):
def generateThumbnail(self, title, image_dir, thumb_file): def generateThumbnail(self, title, image_dir, thumb_file):
import calibre.utils.PythonMagickWand as pw import calibre.utils.PythonMagickWand as pw
try: with pw.ImageMagick():
img = pw.NewMagickWand() try:
if img < 0: img = pw.NewMagickWand()
raise RuntimeError('generate_thumbnail(): Cannot create wand') if img < 0:
# Read the cover raise RuntimeError('generate_thumbnail(): Cannot create wand')
if not pw.MagickReadImage(img, title['cover']): # Read the cover
print 'Failed to read cover image from: %s' % title['cover'] if not pw.MagickReadImage(img,
raise IOError title['cover'].encode(filesystem_encoding)):
thumb = pw.CloneMagickWand(img) print 'Failed to read cover image from: %s' % title['cover']
if thumb < 0: raise IOError
print 'generate_thumbnail(): Cannot clone cover' thumb = pw.CloneMagickWand(img)
raise RuntimeError if thumb < 0:
# img, width, height print 'generate_thumbnail(): Cannot clone cover'
pw.MagickThumbnailImage(thumb, 75, 100) raise RuntimeError
pw.MagickWriteImage(thumb, os.path.join(image_dir, thumb_file)) # img, width, height
pw.DestroyMagickWand(thumb) pw.MagickThumbnailImage(thumb, 75, 100)
except IOError: pw.MagickWriteImage(thumb, os.path.join(image_dir, thumb_file))
print "generate_thumbnail() IOError with %s" % title['title'] pw.DestroyMagickWand(thumb)
except RuntimeError: except IOError:
print "generate_thumbnail() RuntimeError with %s" % title['title'] print "generate_thumbnail() IOError with %s" % title['title']
except RuntimeError:
print "generate_thumbnail() RuntimeError with %s" % title['title']
def processSpecialTags(self, tags, this_title, opts): def processSpecialTags(self, tags, this_title, opts):
tag_list = [] tag_list = []