diff --git a/src/calibre/web/fetch/simple.py b/src/calibre/web/fetch/simple.py index d79ef6204a..5480e3f683 100644 --- a/src/calibre/web/fetch/simple.py +++ b/src/calibre/web/fetch/simple.py @@ -7,7 +7,7 @@ __copyright__ = '2008, Kovid Goyal ' Fetch a webpage and its links recursively. The webpages are saved to disk in UTF-8 encoding with any charset declarations removed. ''' -import sys, socket, os, urlparse, re, time, copy, urllib2, threading, traceback +import sys, socket, os, urlparse, re, time, copy, urllib2, threading, traceback, imghdr from urllib import url2pathname, quote from httplib import responses from PIL import Image @@ -375,16 +375,25 @@ class RecursiveFetcher(object): if isinstance(fname, unicode): fname = fname.encode('ascii', 'replace') imgpath = os.path.join(diskpath, fname+'.jpg') - try: - im = Image.open(StringIO(data)).convert('RGBA') + if (imghdr.what(None, data) is None and b'