From 993fdfa34e1b72af5671ea3fbe6ae5d741f024ac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 22 Jan 2013 22:32:15 +0530 Subject: [PATCH] New download: Do not convert all downloaded images to JPG format. This fixes the problem of PNG images with transparent backgrounds being rendered with black backgrounds --- src/calibre/web/fetch/simple.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/calibre/web/fetch/simple.py b/src/calibre/web/fetch/simple.py index bea45f1c8d..87f97a3395 100644 --- a/src/calibre/web/fetch/simple.py +++ b/src/calibre/web/fetch/simple.py @@ -10,8 +10,6 @@ UTF-8 encoding with any charset declarations removed. 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 -from cStringIO import StringIO from base64 import b64decode from calibre import browser, relpath, unicode_path @@ -21,6 +19,8 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag from calibre.ebooks.chardet import xml_to_unicode from calibre.utils.config import OptionParser from calibre.utils.logging import Log +from calibre.utils.magick import Image +from calibre.utils.magick.draw import identify_data class FetchError(Exception): pass @@ -374,8 +374,8 @@ class RecursiveFetcher(object): fname = ascii_filename('img'+str(c)) if isinstance(fname, unicode): fname = fname.encode('ascii', 'replace') - imgpath = os.path.join(diskpath, fname+'.jpg') - if (imghdr.what(None, data) is None and b'