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 @@ class PMLOutput(OutputFormatPlugin):
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 @@ from __future__ import absolute_import, division, print_function, unicode_litera
__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 @@ I am indebted to esperanc for the initial CSS->Xylog Style conversion code
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 re
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 io
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 @@ class CatalogBuilder(object):
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)