Only import Pillow from PIL

This commit is contained in:
Kovid Goyal 2019-09-09 20:27:20 +05:30
parent 3a6ad1e03a
commit d5bb19f8ec
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
9 changed files with 9 additions and 47 deletions

View file

@ -383,11 +383,7 @@ class WEBOS(USBMS):
def upload_cover(self, path, filename, metadata, filepath):
try:
from PIL import Image, ImageDraw
Image, ImageDraw
except ImportError:
import Image, ImageDraw
from PIL import Image, ImageDraw
coverdata = getattr(metadata, 'thumbnail', None)
if coverdata and coverdata[2]:

View file

@ -48,11 +48,7 @@ class NOOK(USBMS):
SUPPORTS_SUB_DIRS = True
def upload_cover(self, path, filename, metadata, filepath):
try:
from PIL import Image, ImageDraw
Image, ImageDraw
except ImportError:
import Image, ImageDraw
from PIL import Image, ImageDraw
coverdata = getattr(metadata, 'thumbnail', None)
if coverdata and coverdata[2]:

View file

@ -56,11 +56,7 @@ def convert(self, oeb_book, output_path, input_plugin, opts, log):
pmlz.add_dir(tdir)
def write_images(self, manifest, image_hrefs, out_dir, opts):
try:
from PIL import Image
Image
except ImportError:
import Image
from PIL import Image
from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES
for item in manifest:

View file

@ -3,11 +3,7 @@
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
try:
from PIL import ImageFont
ImageFont
except ImportError:
import ImageFont
from PIL import ImageFont
'''
Default fonts used in the PRS500

View file

@ -42,11 +42,7 @@
and to Falstaff for pylrs.
"""
try:
from PIL import Image as PILImage
PILImage
except ImportError:
import Image as PILImage
from PIL import Image as PILImage
def update_css(ncss, ocss):

View file

@ -14,11 +14,7 @@
import struct
import zlib
try:
from PIL import Image
Image
except ImportError:
import Image
from PIL import Image
from calibre.ebooks.pdb.formatwriter import FormatWriter
from calibre.ebooks.pdb.header import PdbHeaderBuilder

View file

@ -9,11 +9,7 @@
import struct
import zlib
try:
from PIL import Image
Image
except ImportError:
import Image
from PIL import Image
from calibre.ebooks.rb.rbml import RBMLizer
from calibre.ebooks.rb import HEADER

View file

@ -89,13 +89,7 @@ def getimagesize(url):
"""
try:
from PIL import ImageFile
except ImportError:
try:
import ImageFile
except ImportError:
return None
from PIL import ImageFile
try:
p = ImageFile.Parser()

View file

@ -2953,11 +2953,7 @@ def generate_masthead_image(self, out_path):
if not font_path or not os.access(font_path, os.R_OK):
font_path = default_font
try:
from PIL import Image, ImageDraw, ImageFont
Image, ImageDraw, ImageFont
except ImportError:
import Image, ImageDraw, ImageFont
from PIL import Image, ImageDraw, ImageFont
img = Image.new('RGB', (MI_WIDTH, MI_HEIGHT), 'white')
draw = ImageDraw.Draw(img)