From 58b5c9187db8bb1c0cf49a35d8996a2179ac2e4c Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 18 Jan 2017 00:22:18 +1100 Subject: [PATCH] Replaced absolute PIL imports with relative imports (#2349) --- PIL/BdfFontFile.py | 3 +-- PIL/BmpImagePlugin.py | 11 +++------ PIL/BufrStubImagePlugin.py | 2 +- PIL/CurImagePlugin.py | 7 ++---- PIL/DcxImagePlugin.py | 7 +++--- PIL/DdsImagePlugin.py | 2 +- PIL/EpsImagePlugin.py | 6 ++--- PIL/FitsStubImagePlugin.py | 2 +- PIL/FliImagePlugin.py | 8 ++----- PIL/FontFile.py | 2 +- PIL/FpxImagePlugin.py | 6 ++--- PIL/FtexImagePlugin.py | 2 +- PIL/GbrImagePlugin.py | 5 ++--- PIL/GdImageFile.py | 7 +++--- PIL/GifImagePlugin.py | 10 +++------ PIL/GimpGradientFile.py | 2 +- PIL/GimpPaletteFile.py | 2 +- PIL/GribStubImagePlugin.py | 2 +- PIL/Hdf5StubImagePlugin.py | 2 +- PIL/IcnsImagePlugin.py | 5 ++--- PIL/IcoImagePlugin.py | 7 ++---- PIL/ImImagePlugin.py | 4 ++-- PIL/Image.py | 46 ++++++++++++++++++-------------------- PIL/ImageChops.py | 2 +- PIL/ImageColor.py | 2 +- PIL/ImageDraw.py | 10 ++++----- PIL/ImageDraw2.py | 2 +- PIL/ImageEnhance.py | 2 +- PIL/ImageFile.py | 4 ++-- PIL/ImageFont.py | 6 ++--- PIL/ImageGrab.py | 4 ++-- PIL/ImageMath.py | 3 +-- PIL/ImageMode.py | 3 ++- PIL/ImageMorph.py | 3 +-- PIL/ImageOps.py | 6 ++--- PIL/ImagePalette.py | 5 +---- PIL/ImagePath.py | 2 +- PIL/ImageQt.py | 4 ++-- PIL/ImageTk.py | 4 ++-- PIL/ImageTransform.py | 2 +- PIL/ImageWin.py | 2 +- PIL/ImtImagePlugin.py | 2 +- PIL/IptcImagePlugin.py | 10 +++------ PIL/Jpeg2KImagePlugin.py | 2 +- PIL/JpegImagePlugin.py | 12 ++++------ PIL/McIdasImagePlugin.py | 2 +- PIL/MicImagePlugin.py | 2 +- PIL/MpegImagePlugin.py | 4 ++-- PIL/MpoImagePlugin.py | 2 +- PIL/MspImagePlugin.py | 7 ++---- PIL/PSDraw.py | 2 +- PIL/PaletteFile.py | 2 +- PIL/PalmImagePlugin.py | 6 ++--- PIL/PcdImagePlugin.py | 5 ++--- PIL/PcfFontFile.py | 11 ++------- PIL/PcxImagePlugin.py | 9 ++------ PIL/PdfImagePlugin.py | 4 ++-- PIL/PixarImagePlugin.py | 6 ++--- PIL/PngImagePlugin.py | 11 ++------- PIL/PpmImagePlugin.py | 2 +- PIL/PsdImagePlugin.py | 10 ++------- PIL/SgiImagePlugin.py | 9 +++----- PIL/SunImagePlugin.py | 21 +++++++++-------- PIL/TarIO.py | 2 +- PIL/TgaImagePlugin.py | 10 ++------- PIL/TiffImagePlugin.py | 13 ++++------- PIL/WalImageFile.py | 5 ++--- PIL/WebPImagePlugin.py | 6 ++--- PIL/WmfImagePlugin.py | 12 ++++------ PIL/XVThumbImagePlugin.py | 5 ++--- PIL/XbmImagePlugin.py | 2 +- PIL/XpmImagePlugin.py | 4 ++-- PIL/features.py | 2 +- 73 files changed, 160 insertions(+), 258 deletions(-) diff --git a/PIL/BdfFontFile.py b/PIL/BdfFontFile.py index b02c44fd2..c8bc60461 100644 --- a/PIL/BdfFontFile.py +++ b/PIL/BdfFontFile.py @@ -19,8 +19,7 @@ from __future__ import print_function -from PIL import Image -from PIL import FontFile +from . import Image, FontFile # -------------------------------------------------------------------- diff --git a/PIL/BmpImagePlugin.py b/PIL/BmpImagePlugin.py index b04981af9..1afe303ab 100644 --- a/PIL/BmpImagePlugin.py +++ b/PIL/BmpImagePlugin.py @@ -24,18 +24,13 @@ # -from PIL import Image, ImageFile, ImagePalette, _binary +from . import Image, ImageFile, ImagePalette +from ._binary import i8, i16le as i16, i32le as i32, \ + o8, o16le as o16, o32le as o32 import math __version__ = "0.7" -i8 = _binary.i8 -i16 = _binary.i16le -i32 = _binary.i32le -o8 = _binary.o8 -o16 = _binary.o16le -o32 = _binary.o32le - # # -------------------------------------------------------------------- # Read BMP file diff --git a/PIL/BufrStubImagePlugin.py b/PIL/BufrStubImagePlugin.py index 5184546e4..4c5da942f 100644 --- a/PIL/BufrStubImagePlugin.py +++ b/PIL/BufrStubImagePlugin.py @@ -9,7 +9,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile +from . import Image, ImageFile _handler = None diff --git a/PIL/CurImagePlugin.py b/PIL/CurImagePlugin.py index 3a9a10e01..e4257cd5a 100644 --- a/PIL/CurImagePlugin.py +++ b/PIL/CurImagePlugin.py @@ -18,17 +18,14 @@ from __future__ import print_function -from PIL import Image, BmpImagePlugin, _binary +from . import Image, BmpImagePlugin +from ._binary import i8, i16le as i16, i32le as i32 __version__ = "0.1" # # -------------------------------------------------------------------- -i8 = _binary.i8 -i16 = _binary.i16le -i32 = _binary.i32le - def _accept(prefix): return prefix[:4] == b"\0\0\2\0" diff --git a/PIL/DcxImagePlugin.py b/PIL/DcxImagePlugin.py index f9034d15c..5663dff5f 100644 --- a/PIL/DcxImagePlugin.py +++ b/PIL/DcxImagePlugin.py @@ -21,15 +21,14 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, _binary -from PIL.PcxImagePlugin import PcxImageFile +from . import Image +from ._binary import i32le as i32 +from .PcxImagePlugin import PcxImageFile __version__ = "0.2" MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then? -i32 = _binary.i32le - def _accept(prefix): return len(prefix) >= 4 and i32(prefix) == MAGIC diff --git a/PIL/DdsImagePlugin.py b/PIL/DdsImagePlugin.py index b6228c2ad..9508e61c8 100644 --- a/PIL/DdsImagePlugin.py +++ b/PIL/DdsImagePlugin.py @@ -12,7 +12,7 @@ Full text of the CC0 license: import struct from io import BytesIO -from PIL import Image, ImageFile +from . import Image, ImageFile # Magic ("DDS ") diff --git a/PIL/EpsImagePlugin.py b/PIL/EpsImagePlugin.py index 77a7e7e1c..8dd3e6857 100644 --- a/PIL/EpsImagePlugin.py +++ b/PIL/EpsImagePlugin.py @@ -23,16 +23,14 @@ import re import io import sys -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import i32le as i32, o32le as o32 __version__ = "0.5" # # -------------------------------------------------------------------- -i32 = _binary.i32le -o32 = _binary.o32le - split = re.compile(r"^%%([^:]*):[ \t]*(.*)[ \t]*$") field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$") diff --git a/PIL/FitsStubImagePlugin.py b/PIL/FitsStubImagePlugin.py index b6ea0e37d..e3a7eb4a6 100644 --- a/PIL/FitsStubImagePlugin.py +++ b/PIL/FitsStubImagePlugin.py @@ -9,7 +9,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile +from . import Image, ImageFile _handler = None diff --git a/PIL/FliImagePlugin.py b/PIL/FliImagePlugin.py index a07dc29b0..429b5e26f 100644 --- a/PIL/FliImagePlugin.py +++ b/PIL/FliImagePlugin.py @@ -16,15 +16,11 @@ # -from PIL import Image, ImageFile, ImagePalette, _binary +from . import Image, ImageFile, ImagePalette +from ._binary import i8, i16le as i16, i32le as i32, o8 __version__ = "0.2" -i8 = _binary.i8 -i16 = _binary.i16le -i32 = _binary.i32le -o8 = _binary.o8 - # # decoder diff --git a/PIL/FontFile.py b/PIL/FontFile.py index 807984a8c..46e49bc4e 100644 --- a/PIL/FontFile.py +++ b/PIL/FontFile.py @@ -17,7 +17,7 @@ from __future__ import print_function import os -from PIL import Image, _binary +from . import Image, _binary WIDTH = 800 diff --git a/PIL/FpxImagePlugin.py b/PIL/FpxImagePlugin.py index 08e7f0da1..23f15f459 100644 --- a/PIL/FpxImagePlugin.py +++ b/PIL/FpxImagePlugin.py @@ -17,15 +17,13 @@ from __future__ import print_function -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import i32le as i32, i8 import olefile __version__ = "0.1" -i32 = _binary.i32le -i8 = _binary.i8 - # we map from colour field tuples to (mode, rawmode) descriptors MODES = { # opacity diff --git a/PIL/FtexImagePlugin.py b/PIL/FtexImagePlugin.py index 4fa462f04..0d08f4cc4 100644 --- a/PIL/FtexImagePlugin.py +++ b/PIL/FtexImagePlugin.py @@ -42,7 +42,7 @@ Note: All data is stored in little-Endian (Intel) byte order. import struct from io import BytesIO -from PIL import Image, ImageFile +from . import Image, ImageFile MAGIC = b"FTEX" diff --git a/PIL/GbrImagePlugin.py b/PIL/GbrImagePlugin.py index d62981c28..b8b9f1a3c 100644 --- a/PIL/GbrImagePlugin.py +++ b/PIL/GbrImagePlugin.py @@ -24,9 +24,8 @@ # Version 3 files have a format specifier of 18 for 16bit floats in # the color depth field. This is currently unsupported by Pillow. -from PIL import Image, ImageFile, _binary - -i32 = _binary.i32be +from . import Image, ImageFile +from ._binary import i32be as i32 def _accept(prefix): diff --git a/PIL/GdImageFile.py b/PIL/GdImageFile.py index 5a07ee230..09ab5ec69 100644 --- a/PIL/GdImageFile.py +++ b/PIL/GdImageFile.py @@ -23,8 +23,9 @@ # purposes only. -from PIL import ImageFile, ImagePalette, _binary -from PIL._util import isPath +from . import ImageFile, ImagePalette +from ._binary import i16be as i16 +from ._util import isPath __version__ = "0.1" @@ -34,8 +35,6 @@ except ImportError: import __builtin__ builtins = __builtin__ -i16 = _binary.i16be - ## # Image plugin for the GD uncompressed format. Note that this format diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py index a50af6c02..2e519c7ac 100644 --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -24,8 +24,9 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile, ImagePalette, \ - ImageChops, ImageSequence, _binary +from . import Image, ImageFile, ImagePalette, \ + ImageChops, ImageSequence +from ._binary import i8, i16le as i16, o8, o16le as o16 __version__ = "0.9" @@ -33,11 +34,6 @@ __version__ = "0.9" # -------------------------------------------------------------------- # Helpers -i8 = _binary.i8 -i16 = _binary.i16le -o8 = _binary.o8 -o16 = _binary.o16le - # -------------------------------------------------------------------- # Identify/read GIF files diff --git a/PIL/GimpGradientFile.py b/PIL/GimpGradientFile.py index 45af573bb..43cd72649 100644 --- a/PIL/GimpGradientFile.py +++ b/PIL/GimpGradientFile.py @@ -14,7 +14,7 @@ # from math import pi, log, sin, sqrt -from PIL._binary import o8 +from ._binary import o8 # -------------------------------------------------------------------- # Stuff to translate curve segments to palette values (derived from diff --git a/PIL/GimpPaletteFile.py b/PIL/GimpPaletteFile.py index e4b4641e5..6eef6a2dd 100644 --- a/PIL/GimpPaletteFile.py +++ b/PIL/GimpPaletteFile.py @@ -15,7 +15,7 @@ # import re -from PIL._binary import o8 +from ._binary import o8 ## diff --git a/PIL/GribStubImagePlugin.py b/PIL/GribStubImagePlugin.py index e880e5281..1fbfe61dc 100644 --- a/PIL/GribStubImagePlugin.py +++ b/PIL/GribStubImagePlugin.py @@ -9,7 +9,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile +from . import Image, ImageFile _handler = None diff --git a/PIL/Hdf5StubImagePlugin.py b/PIL/Hdf5StubImagePlugin.py index dc85084d8..a5d6b1bc1 100644 --- a/PIL/Hdf5StubImagePlugin.py +++ b/PIL/Hdf5StubImagePlugin.py @@ -9,7 +9,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile +from . import Image, ImageFile _handler = None diff --git a/PIL/IcnsImagePlugin.py b/PIL/IcnsImagePlugin.py index 089fc2a44..cb215fe3e 100644 --- a/PIL/IcnsImagePlugin.py +++ b/PIL/IcnsImagePlugin.py @@ -15,7 +15,8 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile, PngImagePlugin, _binary +from PIL import Image, ImageFile, PngImagePlugin +from PIL._binary import i8 import io import os import shutil @@ -27,8 +28,6 @@ enable_jpeg2k = hasattr(Image.core, 'jp2klib_version') if enable_jpeg2k: from PIL import Jpeg2KImagePlugin -i8 = _binary.i8 - HEADERSIZE = 8 diff --git a/PIL/IcoImagePlugin.py b/PIL/IcoImagePlugin.py index 3436ae84f..e4db4e766 100644 --- a/PIL/IcoImagePlugin.py +++ b/PIL/IcoImagePlugin.py @@ -25,7 +25,8 @@ import struct from io import BytesIO -from PIL import Image, ImageFile, BmpImagePlugin, PngImagePlugin, _binary +from . import Image, ImageFile, BmpImagePlugin, PngImagePlugin +from ._binary import i8, i16le as i16, i32le as i32 from math import log, ceil __version__ = "0.1" @@ -33,10 +34,6 @@ __version__ = "0.1" # # -------------------------------------------------------------------- -i8 = _binary.i8 -i16 = _binary.i16le -i32 = _binary.i32le - _MAGIC = b"\0\0\1\0" diff --git a/PIL/ImImagePlugin.py b/PIL/ImImagePlugin.py index dd4f82900..4638419fa 100644 --- a/PIL/ImImagePlugin.py +++ b/PIL/ImImagePlugin.py @@ -27,8 +27,8 @@ import re -from PIL import Image, ImageFile, ImagePalette -from PIL._binary import i8 +from . import Image, ImageFile, ImagePalette +from ._binary import i8 __version__ = "0.7" diff --git a/PIL/Image.py b/PIL/Image.py index e368ef187..dbe916df1 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -26,7 +26,7 @@ from __future__ import print_function -from PIL import VERSION, PILLOW_VERSION, _plugins +from . import VERSION, PILLOW_VERSION, _plugins import logging import warnings @@ -64,7 +64,7 @@ try: # import Image and use the Image.core variable instead. # Also note that Image.core is not a publicly documented interface, # and should be considered private and subject to change. - from PIL import _imaging as core + from . import _imaging as core if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None): raise ImportError("The _imaging extension was built for another " "version of Pillow or PIL") @@ -109,11 +109,9 @@ except ImportError: import __builtin__ builtins = __builtin__ -from PIL import ImageMode -from PIL._binary import i8 -from PIL._util import isPath -from PIL._util import isStringType -from PIL._util import deferred_error +from . import ImageMode +from ._binary import i8 +from ._util import isPath, isStringType, deferred_error import os import sys @@ -355,23 +353,23 @@ def preinit(): return try: - from PIL import BmpImagePlugin + from . import BmpImagePlugin except ImportError: pass try: - from PIL import GifImagePlugin + from . import GifImagePlugin except ImportError: pass try: - from PIL import JpegImagePlugin + from . import JpegImagePlugin except ImportError: pass try: - from PIL import PpmImagePlugin + from . import PpmImagePlugin except ImportError: pass try: - from PIL import PngImagePlugin + from . import PngImagePlugin except ImportError: pass # try: @@ -525,7 +523,7 @@ class Image(object): if self.palette: new.palette = self.palette.copy() if im.mode == "P" and not new.palette: - from PIL import ImagePalette + from . import ImagePalette new.palette = ImagePalette.ImagePalette() new.info = self.info.copy() return new @@ -775,7 +773,7 @@ class Image(object): if HAS_CFFI and USE_CFFI_ACCESS: if self.pyaccess: return self.pyaccess - from PIL import PyAccess + from . import PyAccess self.pyaccess = PyAccess.new(self, self.readonly) if self.pyaccess: return self.pyaccess @@ -908,7 +906,7 @@ class Image(object): if mode == "P" and palette == ADAPTIVE: im = self.im.quantize(colors) new = self._new(im) - from PIL import ImagePalette + from . import ImagePalette new.palette = ImagePalette.raw("RGB", new.im.getpalette("RGB")) if delete_trns: # This could possibly happen if we requantize to fewer colors. @@ -1321,7 +1319,7 @@ class Image(object): box += (box[0]+size[0], box[1]+size[1]) if isStringType(im): - from PIL import ImageColor + from . import ImageColor im = ImageColor.getcolor(im, self.mode) elif isImageType(im): @@ -1468,7 +1466,7 @@ class Image(object): :param data: A palette sequence (either a list or a string). """ - from PIL import ImagePalette + from . import ImagePalette if self.mode not in ("L", "P"): raise ValueError("illegal image mode") @@ -1583,7 +1581,7 @@ class Image(object): angle = angle % 360.0 # Fast paths regardless of filter, as long as we're not - # translating or changing the center. + # translating or changing the center. if not (center or translate): if angle == 0: return self.copy() @@ -1977,14 +1975,14 @@ class Image(object): def toqimage(self): """Returns a QImage copy of this image""" - from PIL import ImageQt + from . import ImageQt if not ImageQt.qt_is_installed: raise ImportError("Qt bindings are not installed") return ImageQt.toqimage(self) def toqpixmap(self): """Returns a QPixmap copy of this image""" - from PIL import ImageQt + from . import ImageQt if not ImageQt.qt_is_installed: raise ImportError("Qt bindings are not installed") return ImageQt.toqpixmap(self) @@ -2057,7 +2055,7 @@ def new(mode, size, color=0): if isStringType(color): # css3-style specifier - from PIL import ImageColor + from . import ImageColor color = ImageColor.getcolor(color, mode) return Image()._new(core.fill(mode, size, color)) @@ -2219,7 +2217,7 @@ def fromarray(obj, mode=None): def fromqimage(im): """Creates an image instance from a QImage image""" - from PIL import ImageQt + from . import ImageQt if not ImageQt.qt_is_installed: raise ImportError("Qt bindings are not installed") return ImageQt.fromqimage(im) @@ -2227,7 +2225,7 @@ def fromqimage(im): def fromqpixmap(im): """Creates an image instance from a QPixmap image""" - from PIL import ImageQt + from . import ImageQt if not ImageQt.qt_is_installed: raise ImportError("Qt bindings are not installed") return ImageQt.fromqpixmap(im) @@ -2531,7 +2529,7 @@ def _show(image, **options): def _showxv(image, title=None, **options): - from PIL import ImageShow + from . import ImageShow ImageShow.show(image, title, **options) diff --git a/PIL/ImageChops.py b/PIL/ImageChops.py index ba5350e02..89016730e 100644 --- a/PIL/ImageChops.py +++ b/PIL/ImageChops.py @@ -15,7 +15,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image +from . import Image def constant(image, value): diff --git a/PIL/ImageColor.py b/PIL/ImageColor.py index 64eebfe9d..1c7bc31d5 100644 --- a/PIL/ImageColor.py +++ b/PIL/ImageColor.py @@ -17,7 +17,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image +from . import Image import re diff --git a/PIL/ImageDraw.py b/PIL/ImageDraw.py index 720403920..6b72fcab7 100644 --- a/PIL/ImageDraw.py +++ b/PIL/ImageDraw.py @@ -33,8 +33,8 @@ import numbers import warnings -from PIL import Image, ImageColor -from PIL._util import isStringType +from . import Image, ImageColor +from ._util import isStringType """ A simple 2D drawing interface for PIL images. @@ -105,7 +105,7 @@ class ImageDraw(object): """Get the current default font.""" if not self.font: # FIXME: should add a font repository - from PIL import ImageFont + from . import ImageFont self.font = ImageFont.load_default() return self.font @@ -319,11 +319,11 @@ def getdraw(im=None, hints=None): handler = None if not hints or "nicest" in hints: try: - from PIL import _imagingagg as handler + from . import _imagingagg as handler except ImportError: pass if handler is None: - from PIL import ImageDraw2 as handler + from . import ImageDraw2 as handler if im: im = handler.Draw(im) return im, handler diff --git a/PIL/ImageDraw2.py b/PIL/ImageDraw2.py index 62ee11630..a1763350d 100644 --- a/PIL/ImageDraw2.py +++ b/PIL/ImageDraw2.py @@ -16,7 +16,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageColor, ImageDraw, ImageFont, ImagePath +from . import Image, ImageColor, ImageDraw, ImageFont, ImagePath class Pen(object): diff --git a/PIL/ImageEnhance.py b/PIL/ImageEnhance.py index 56b5c0199..b38f406a3 100644 --- a/PIL/ImageEnhance.py +++ b/PIL/ImageEnhance.py @@ -18,7 +18,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFilter, ImageStat +from . import Image, ImageFilter, ImageStat class _Enhance(object): diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py index a56795751..8f3ee524c 100644 --- a/PIL/ImageFile.py +++ b/PIL/ImageFile.py @@ -27,8 +27,8 @@ # See the README file for information on usage and redistribution. # -from PIL import Image -from PIL._util import isPath +from . import Image +from ._util import isPath import io import os import sys diff --git a/PIL/ImageFont.py b/PIL/ImageFont.py index 49494b33f..c74d00138 100644 --- a/PIL/ImageFont.py +++ b/PIL/ImageFont.py @@ -25,8 +25,8 @@ # See the README file for information on usage and redistribution. # -from PIL import Image -from PIL._util import isDirectory, isPath +from . import Image +from ._util import isDirectory, isPath import os import sys @@ -37,7 +37,7 @@ class _imagingft_not_installed(object): raise ImportError("The _imagingft C module is not installed") try: - from PIL import _imagingft as core + from . import _imagingft as core except ImportError: core = _imagingft_not_installed() diff --git a/PIL/ImageGrab.py b/PIL/ImageGrab.py index 03283f3d6..938d0e994 100644 --- a/PIL/ImageGrab.py +++ b/PIL/ImageGrab.py @@ -15,7 +15,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image +from . import Image import sys if sys.platform not in ["win32", "darwin"]: @@ -75,7 +75,7 @@ def grabclipboard(): debug = 0 # temporary interface data = Image.core.grabclipboard(debug) if isinstance(data, bytes): - from PIL import BmpImagePlugin + from . import BmpImagePlugin import io return BmpImagePlugin.DibImageFile(io.BytesIO(data)) return data diff --git a/PIL/ImageMath.py b/PIL/ImageMath.py index 897f0aeb1..2ccd1891b 100644 --- a/PIL/ImageMath.py +++ b/PIL/ImageMath.py @@ -15,8 +15,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image -from PIL import _imagingmath +from . import Image, _imagingmath try: import builtins diff --git a/PIL/ImageMode.py b/PIL/ImageMode.py index 93dbeab41..b227f2127 100644 --- a/PIL/ImageMode.py +++ b/PIL/ImageMode.py @@ -35,7 +35,8 @@ def getmode(mode): global _modes if not _modes: # initialize mode cache - from PIL import Image + + from . import Image modes = {} # core modes for m, (basemode, basetype, bands) in Image._MODEINFO.items(): diff --git a/PIL/ImageMorph.py b/PIL/ImageMorph.py index 3ad708291..8382f7ce0 100644 --- a/PIL/ImageMorph.py +++ b/PIL/ImageMorph.py @@ -7,8 +7,7 @@ from __future__ import print_function -from PIL import Image -from PIL import _imagingmorph +from . import Image, _imagingmorph import re LUT_SIZE = 1 << 9 diff --git a/PIL/ImageOps.py b/PIL/ImageOps.py index 182f3c3d2..3681109c1 100644 --- a/PIL/ImageOps.py +++ b/PIL/ImageOps.py @@ -17,8 +17,8 @@ # See the README file for information on usage and redistribution. # -from PIL import Image -from PIL._util import isStringType +from . import Image +from ._util import isStringType import operator import functools @@ -39,7 +39,7 @@ def _border(border): def _color(color, mode): if isStringType(color): - from PIL import ImageColor + from . import ImageColor color = ImageColor.getcolor(color, mode) return color diff --git a/PIL/ImagePalette.py b/PIL/ImagePalette.py index 8bf09385c..cecc64583 100644 --- a/PIL/ImagePalette.py +++ b/PIL/ImagePalette.py @@ -17,10 +17,7 @@ # import array -from PIL import ImageColor -from PIL import GimpPaletteFile -from PIL import GimpGradientFile -from PIL import PaletteFile +from . import ImageColor, GimpPaletteFile, GimpGradientFile, PaletteFile class ImagePalette(object): diff --git a/PIL/ImagePath.py b/PIL/ImagePath.py index 3abfba031..1543508e4 100644 --- a/PIL/ImagePath.py +++ b/PIL/ImagePath.py @@ -14,7 +14,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image +from . import Image # the Python class below is overridden by the C implementation. diff --git a/PIL/ImageQt.py b/PIL/ImageQt.py index 2ce89e7ad..36b4e1ebc 100644 --- a/PIL/ImageQt.py +++ b/PIL/ImageQt.py @@ -16,8 +16,8 @@ # See the README file for information on usage and redistribution. # -from PIL import Image -from PIL._util import isPath +from . import Image +from ._util import isPath from io import BytesIO qt_is_installed = True diff --git a/PIL/ImageTk.py b/PIL/ImageTk.py index d3957b6d1..25c4534ce 100644 --- a/PIL/ImageTk.py +++ b/PIL/ImageTk.py @@ -32,7 +32,7 @@ except ImportError: tkinter = Tkinter del Tkinter -from PIL import Image +from . import Image from io import BytesIO @@ -182,7 +182,7 @@ class PhotoImage(object): except tkinter.TclError: # activate Tkinter hook try: - from PIL import _imagingtk + from . import _imagingtk try: _imagingtk.tkinit(tk.interpaddr(), 1) except AttributeError: diff --git a/PIL/ImageTransform.py b/PIL/ImageTransform.py index 92cc2c7e0..dcfcdfae8 100644 --- a/PIL/ImageTransform.py +++ b/PIL/ImageTransform.py @@ -13,7 +13,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image +from . import Image class Transform(Image.ImageTransformHandler): diff --git a/PIL/ImageWin.py b/PIL/ImageWin.py index 514fc4ff8..cc4dced97 100644 --- a/PIL/ImageWin.py +++ b/PIL/ImageWin.py @@ -17,7 +17,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image +from . import Image class HDC(object): diff --git a/PIL/ImtImagePlugin.py b/PIL/ImtImagePlugin.py index e95f7aeba..05e8cd31a 100644 --- a/PIL/ImtImagePlugin.py +++ b/PIL/ImtImagePlugin.py @@ -17,7 +17,7 @@ import re -from PIL import Image, ImageFile +from . import Image, ImageFile __version__ = "0.2" diff --git a/PIL/IptcImagePlugin.py b/PIL/IptcImagePlugin.py index 319e6abfe..8941643bb 100644 --- a/PIL/IptcImagePlugin.py +++ b/PIL/IptcImagePlugin.py @@ -17,17 +17,13 @@ from __future__ import print_function -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import i8, i16be as i16, i32be as i32, o8 import os import tempfile __version__ = "0.3" -i8 = _binary.i8 -i16 = _binary.i16be -i32 = _binary.i32be -o8 = _binary.o8 - COMPRESSION = { 1: "raw", 5: "jpeg" @@ -191,7 +187,7 @@ def getiptcinfo(im): :returns: A dictionary containing IPTC information, or None if no IPTC information block was found. """ - from PIL import TiffImagePlugin, JpegImagePlugin + from . import TiffImagePlugin, JpegImagePlugin import io data = None diff --git a/PIL/Jpeg2KImagePlugin.py b/PIL/Jpeg2KImagePlugin.py index 66de34bfa..101f55f76 100644 --- a/PIL/Jpeg2KImagePlugin.py +++ b/PIL/Jpeg2KImagePlugin.py @@ -12,7 +12,7 @@ # # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile +from . import Image, ImageFile import struct import os import io diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index 3976ff55a..f01885b60 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -38,14 +38,10 @@ import array import struct import io import warnings -from PIL import Image, ImageFile, TiffImagePlugin, _binary -from PIL.JpegPresets import presets -from PIL._util import isStringType - -i8 = _binary.i8 -o8 = _binary.o8 -i16 = _binary.i16be -i32 = _binary.i32be +from . import Image, ImageFile, TiffImagePlugin +from ._binary import i8, o8, i16be as i16, i32be as i32 +from .JpegPresets import presets +from ._util import isStringType __version__ = "0.6" diff --git a/PIL/McIdasImagePlugin.py b/PIL/McIdasImagePlugin.py index b75360353..08eeec39f 100644 --- a/PIL/McIdasImagePlugin.py +++ b/PIL/McIdasImagePlugin.py @@ -17,7 +17,7 @@ # import struct -from PIL import Image, ImageFile +from . import Image, ImageFile __version__ = "0.2" diff --git a/PIL/MicImagePlugin.py b/PIL/MicImagePlugin.py index 125e297ac..a70838b07 100644 --- a/PIL/MicImagePlugin.py +++ b/PIL/MicImagePlugin.py @@ -17,7 +17,7 @@ # -from PIL import Image, TiffImagePlugin +from . import Image, TiffImagePlugin import olefile diff --git a/PIL/MpegImagePlugin.py b/PIL/MpegImagePlugin.py index 6671b8691..bdc5e3689 100644 --- a/PIL/MpegImagePlugin.py +++ b/PIL/MpegImagePlugin.py @@ -14,8 +14,8 @@ # -from PIL import Image, ImageFile -from PIL._binary import i8 +from . import Image, ImageFile +from ._binary import i8 __version__ = "0.1" diff --git a/PIL/MpoImagePlugin.py b/PIL/MpoImagePlugin.py index 1d26021d8..9341c530c 100644 --- a/PIL/MpoImagePlugin.py +++ b/PIL/MpoImagePlugin.py @@ -18,7 +18,7 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, JpegImagePlugin +from . import Image, JpegImagePlugin __version__ = "0.1" diff --git a/PIL/MspImagePlugin.py b/PIL/MspImagePlugin.py index 85f8e764b..b60a21d69 100644 --- a/PIL/MspImagePlugin.py +++ b/PIL/MspImagePlugin.py @@ -17,7 +17,8 @@ # -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import i16le as i16, o16le as o16 __version__ = "0.1" @@ -25,8 +26,6 @@ __version__ = "0.1" # # read MSP files -i16 = _binary.i16le - def _accept(prefix): return prefix[:4] in [b"DanM", b"LinS"] @@ -66,8 +65,6 @@ class MspImageFile(ImageFile.ImageFile): # # write MSP files (uncompressed only) -o16 = _binary.o16le - def _save(im, fp, filename): diff --git a/PIL/PSDraw.py b/PIL/PSDraw.py index d4e7b18cc..fe0823860 100644 --- a/PIL/PSDraw.py +++ b/PIL/PSDraw.py @@ -15,7 +15,7 @@ # See the README file for information on usage and redistribution. # -from PIL import EpsImagePlugin +from . import EpsImagePlugin import sys ## diff --git a/PIL/PaletteFile.py b/PIL/PaletteFile.py index ef50feefd..9ed69d687 100644 --- a/PIL/PaletteFile.py +++ b/PIL/PaletteFile.py @@ -13,7 +13,7 @@ # See the README file for information on usage and redistribution. # -from PIL._binary import o8 +from ._binary import o8 ## diff --git a/PIL/PalmImagePlugin.py b/PIL/PalmImagePlugin.py index d02839bdf..cb4e491c0 100644 --- a/PIL/PalmImagePlugin.py +++ b/PIL/PalmImagePlugin.py @@ -7,7 +7,8 @@ # Image plugin for Palm pixmap images (output only). ## -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import o8, o16be as o16b __version__ = "1.0" @@ -108,9 +109,6 @@ _COMPRESSION_TYPES = { "scanline": 0x00, } -o8 = _binary.o8 -o16b = _binary.o16be - # # -------------------------------------------------------------------- diff --git a/PIL/PcdImagePlugin.py b/PIL/PcdImagePlugin.py index 24186bcfc..fa95b5008 100644 --- a/PIL/PcdImagePlugin.py +++ b/PIL/PcdImagePlugin.py @@ -15,12 +15,11 @@ # -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import i8 __version__ = "0.1" -i8 = _binary.i8 - ## # Image plugin for PhotoCD images. This plugin only reads the 768x512 diff --git a/PIL/PcfFontFile.py b/PIL/PcfFontFile.py index c2006905e..eba85feb0 100644 --- a/PIL/PcfFontFile.py +++ b/PIL/PcfFontFile.py @@ -16,9 +16,8 @@ # See the README file for information on usage and redistribution. # -from PIL import Image -from PIL import FontFile -from PIL import _binary +from . import Image, FontFile +from ._binary import i8, i16le as l16, i32le as l32, i16be as b16, i32be as b32 # -------------------------------------------------------------------- # declarations @@ -42,12 +41,6 @@ BYTES_PER_ROW = [ lambda bits: ((bits+63) >> 3) & ~7, ] -i8 = _binary.i8 -l16 = _binary.i16le -l32 = _binary.i32le -b16 = _binary.i16be -b32 = _binary.i32be - def sz(s, o): return s[o:s.index(b"\0", o)] diff --git a/PIL/PcxImagePlugin.py b/PIL/PcxImagePlugin.py index 9440d5362..e3c008f4f 100644 --- a/PIL/PcxImagePlugin.py +++ b/PIL/PcxImagePlugin.py @@ -28,14 +28,11 @@ from __future__ import print_function import logging -from PIL import Image, ImageFile, ImagePalette, _binary +from . import Image, ImageFile, ImagePalette +from ._binary import i8, i16le as i16, o8, o16le as o16 logger = logging.getLogger(__name__) -i8 = _binary.i8 -i16 = _binary.i16le -o8 = _binary.o8 - __version__ = "0.6" @@ -123,8 +120,6 @@ SAVE = { "RGB": (5, 8, 3, "RGB;L"), } -o16 = _binary.o16le - def _save(im, fp, filename, check=0): diff --git a/PIL/PdfImagePlugin.py b/PIL/PdfImagePlugin.py index 7decf0ee5..b615fe1e0 100644 --- a/PIL/PdfImagePlugin.py +++ b/PIL/PdfImagePlugin.py @@ -20,8 +20,8 @@ # Image plugin for PDF images (output only). ## -from PIL import Image, ImageFile -from PIL._binary import i8 +from . import Image, ImageFile +from ._binary import i8 import io __version__ = "0.4" diff --git a/PIL/PixarImagePlugin.py b/PIL/PixarImagePlugin.py index fd002d9cf..732d8c692 100644 --- a/PIL/PixarImagePlugin.py +++ b/PIL/PixarImagePlugin.py @@ -19,16 +19,14 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import i16le as i16 __version__ = "0.1" # # helpers -i16 = _binary.i16le - - def _accept(prefix): return prefix[:4] == b"\200\350\000\000" diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index 4d6f9d7ff..dca8a456e 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -38,16 +38,13 @@ import re import zlib import struct -from PIL import Image, ImageFile, ImagePalette, _binary +from . import Image, ImageFile, ImagePalette +from ._binary import i8, i16be as i16, i32be as i32, o8, o16be as o16, o32be as o32 __version__ = "0.9" logger = logging.getLogger(__name__) -i8 = _binary.i8 -i16 = _binary.i16be -i32 = _binary.i32be - is_cid = re.compile(br"\w\w\w\w").match @@ -621,10 +618,6 @@ class PngImageFile(ImageFile.ImageFile): # -------------------------------------------------------------------- # PNG writer -o8 = _binary.o8 -o16 = _binary.o16be -o32 = _binary.o32be - _OUTMODES = { # supported PIL modes, and corresponding rawmodes/bits/color combinations "1": ("1", b'\x01\x00'), diff --git a/PIL/PpmImagePlugin.py b/PIL/PpmImagePlugin.py index adaf8384c..b91f9912b 100644 --- a/PIL/PpmImagePlugin.py +++ b/PIL/PpmImagePlugin.py @@ -17,7 +17,7 @@ import string -from PIL import Image, ImageFile +from . import Image, ImageFile __version__ = "0.2" diff --git a/PIL/PsdImagePlugin.py b/PIL/PsdImagePlugin.py index d06e320b0..1e4051c29 100644 --- a/PIL/PsdImagePlugin.py +++ b/PIL/PsdImagePlugin.py @@ -18,7 +18,8 @@ __version__ = "0.4" -from PIL import Image, ImageFile, ImagePalette, _binary +from . import Image, ImageFile, ImagePalette +from ._binary import i8, i16be as i16, i32be as i32 MODES = { # (photoshop mode, bits) -> (pil mode, required channels) @@ -33,13 +34,6 @@ MODES = { (9, 8): ("LAB", 3) } -# -# helpers - -i8 = _binary.i8 -i16 = _binary.i16be -i32 = _binary.i32be - # --------------------------------------------------------------------. # read PSD images diff --git a/PIL/SgiImagePlugin.py b/PIL/SgiImagePlugin.py index d0e293368..973c68567 100644 --- a/PIL/SgiImagePlugin.py +++ b/PIL/SgiImagePlugin.py @@ -21,16 +21,13 @@ # -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import i8, o8, i16be as i16 import struct import os __version__ = "0.3" -i8 = _binary.i8 -o8 = _binary.o8 -i16 = _binary.i16be - def _accept(prefix): return len(prefix) >= 2 and i16(prefix) == 474 @@ -134,7 +131,7 @@ def _save(im, fp, filename): fp.write(struct.pack('404s', b'')) # dummy - #assert we've got the right number of bands. + #assert we've got the right number of bands. if len(im.getbands()) != z: raise ValueError("incorrect number of bands in SGI write: %s vs %s" % (z, len(im.getbands()))) diff --git a/PIL/SunImagePlugin.py b/PIL/SunImagePlugin.py index c3e2bc402..876fb73fa 100644 --- a/PIL/SunImagePlugin.py +++ b/PIL/SunImagePlugin.py @@ -17,12 +17,11 @@ # -from PIL import Image, ImageFile, ImagePalette, _binary +from . import Image, ImageFile, ImagePalette +from ._binary import i32be as i32 __version__ = "0.3" -i32 = _binary.i32be - def _accept(prefix): return len(prefix) >= 4 and i32(prefix) == 0x59a66a95 @@ -63,11 +62,11 @@ class SunImageFile(ImageFile.ImageFile): self.size = i32(s[4:8]), i32(s[8:12]) depth = i32(s[12:16]) - data_length = i32(s[16:20]) # unreliable, ignore. + data_length = i32(s[16:20]) # unreliable, ignore. file_type = i32(s[20:24]) palette_type = i32(s[24:28]) # 0: None, 1: RGB, 2: Raw/arbitrary palette_length = i32(s[28:32]) - + if depth == 1: self.mode, rawmode = "1", "1;I" elif depth == 4: @@ -85,23 +84,23 @@ class SunImageFile(ImageFile.ImageFile): else: self.mode, rawmode = 'RGB', 'BGRX' else: - raise SyntaxError("Unsupported Mode/Bit Depth") - + raise SyntaxError("Unsupported Mode/Bit Depth") + if palette_length: if palette_length > 1024: raise SyntaxError("Unsupported Color Palette Length") if palette_type != 1: raise SyntaxError("Unsupported Palette Type") - + offset = offset + palette_length self.palette = ImagePalette.raw("RGB;L", self.fp.read(palette_length)) if self.mode == "L": self.mode = "P" rawmode = rawmode.replace('L', 'P') - + # 16 bit boundaries on stride - stride = ((self.size[0] * depth + 15) // 16) * 2 + stride = ((self.size[0] * depth + 15) // 16) * 2 # file type: Type is the version (or flavor) of the bitmap # file. The following values are typically found in the Type @@ -127,7 +126,7 @@ class SunImageFile(ImageFile.ImageFile): self.tile = [("sun_rle", (0, 0)+self.size, offset, rawmode)] else: raise SyntaxError('Unsupported Sun Raster file type') - + # # registry diff --git a/PIL/TarIO.py b/PIL/TarIO.py index 4f3182848..0e949ff88 100644 --- a/PIL/TarIO.py +++ b/PIL/TarIO.py @@ -14,7 +14,7 @@ # See the README file for information on usage and redistribution. # -from PIL import ContainerIO +from . import ContainerIO ## diff --git a/PIL/TgaImagePlugin.py b/PIL/TgaImagePlugin.py index a75ce2986..de2844339 100644 --- a/PIL/TgaImagePlugin.py +++ b/PIL/TgaImagePlugin.py @@ -17,7 +17,8 @@ # -from PIL import Image, ImageFile, ImagePalette, _binary +from . import Image, ImageFile, ImagePalette +from ._binary import i8, i16le as i16, o8, o16le as o16, o32le as o32 __version__ = "0.3" @@ -26,9 +27,6 @@ __version__ = "0.3" # -------------------------------------------------------------------- # Read RGA file -i8 = _binary.i8 -i16 = _binary.i16le - MODES = { # map imagetype/depth to rawmode @@ -132,10 +130,6 @@ class TgaImageFile(ImageFile.ImageFile): # -------------------------------------------------------------------- # Write TGA file -o8 = _binary.o8 -o16 = _binary.o16le -o32 = _binary.o32le - SAVE = { "1": ("1", 1, 0, 3), "L": ("L", 8, 0, 3), diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index ae98831d2..e5009d0f1 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -41,10 +41,8 @@ from __future__ import division, print_function -from PIL import Image, ImageFile -from PIL import ImagePalette -from PIL import _binary -from PIL import TiffTags +from . import Image, ImageFile, ImagePalette, TiffTags +from ._binary import i8, o8 import collections from fractions import Fraction @@ -71,9 +69,6 @@ IFD_LEGACY_API = True II = b"II" # little-endian (Intel style) MM = b"MM" # big-endian (Motorola style) -i8 = _binary.i8 -o8 = _binary.o8 - # # -------------------------------------------------------------------- # Read TIFF files @@ -569,7 +564,7 @@ class ImageFileDirectory_v2(collections.MutableMapping): def _register_loader(idx, size): def decorator(func): - from PIL.TiffTags import TYPES + from .TiffTags import TYPES if func.__name__.startswith("load_"): TYPES[idx] = func.__name__[5:].replace("_", " ") _load_dispatch[idx] = size, func @@ -583,7 +578,7 @@ class ImageFileDirectory_v2(collections.MutableMapping): return decorator def _register_basic(idx_fmt_name): - from PIL.TiffTags import TYPES + from .TiffTags import TYPES idx, fmt, name = idx_fmt_name TYPES[idx] = name size = struct.calcsize("=" + fmt) diff --git a/PIL/WalImageFile.py b/PIL/WalImageFile.py index 1167fa739..a17238a5a 100644 --- a/PIL/WalImageFile.py +++ b/PIL/WalImageFile.py @@ -23,7 +23,8 @@ from __future__ import print_function -from PIL import Image, _binary +from . import Image +from ._binary import i32le as i32 try: import builtins @@ -31,8 +32,6 @@ except ImportError: import __builtin__ builtins = __builtin__ -i32 = _binary.i32le - def open(filename): """ diff --git a/PIL/WebPImagePlugin.py b/PIL/WebPImagePlugin.py index 6837b53be..b93e0d3e7 100644 --- a/PIL/WebPImagePlugin.py +++ b/PIL/WebPImagePlugin.py @@ -1,7 +1,5 @@ -from PIL import Image -from PIL import ImageFile +from . import Image, ImageFile, _webp from io import BytesIO -from PIL import _webp _VALID_WEBP_MODES = { @@ -43,7 +41,7 @@ class WebPImageFile(ImageFile.ImageFile): self.tile = [("raw", (0, 0) + self.size, 0, self.mode)] def _getexif(self): - from PIL.JpegImagePlugin import _getexif + from .JpegImagePlugin import _getexif return _getexif(self) diff --git a/PIL/WmfImagePlugin.py b/PIL/WmfImagePlugin.py index 99e498226..f7076c0d9 100644 --- a/PIL/WmfImagePlugin.py +++ b/PIL/WmfImagePlugin.py @@ -21,7 +21,10 @@ from __future__ import print_function -from PIL import Image, ImageFile, _binary +from . import Image, ImageFile +from ._binary import i16le as word, si16le as short, i32le as dword, si32le as _long + + __version__ = "0.2" @@ -59,13 +62,6 @@ if hasattr(Image.core, "drawwmf"): register_handler(WmfHandler()) -# -------------------------------------------------------------------- - -word = _binary.i16le -short = _binary.si16le -dword = _binary.i32le -_long = _binary.si32le - # # -------------------------------------------------------------------- # Read WMF file diff --git a/PIL/XVThumbImagePlugin.py b/PIL/XVThumbImagePlugin.py index 0034ff7d0..6929e8b82 100644 --- a/PIL/XVThumbImagePlugin.py +++ b/PIL/XVThumbImagePlugin.py @@ -17,12 +17,11 @@ # FIXME: make save work (this requires quantization support) # -from PIL import Image, ImageFile, ImagePalette, _binary +from . import Image, ImageFile, ImagePalette +from ._binary import o8 __version__ = "0.1" -o8 = _binary.o8 - _MAGIC = b"P7 332" # standard color palette for thumbnails (RGB332) diff --git a/PIL/XbmImagePlugin.py b/PIL/XbmImagePlugin.py index d0b0e47ab..b43fbef50 100644 --- a/PIL/XbmImagePlugin.py +++ b/PIL/XbmImagePlugin.py @@ -20,7 +20,7 @@ # import re -from PIL import Image, ImageFile +from . import Image, ImageFile __version__ = "0.6" diff --git a/PIL/XpmImagePlugin.py b/PIL/XpmImagePlugin.py index 556adb8f7..87736aff9 100644 --- a/PIL/XpmImagePlugin.py +++ b/PIL/XpmImagePlugin.py @@ -16,8 +16,8 @@ import re -from PIL import Image, ImageFile, ImagePalette -from PIL._binary import i8, o8 +from . import Image, ImageFile, ImagePalette +from ._binary import i8, o8 __version__ = "0.2" diff --git a/PIL/features.py b/PIL/features.py index 134d85abf..fb8e4371b 100644 --- a/PIL/features.py +++ b/PIL/features.py @@ -1,4 +1,4 @@ -from PIL import Image +from . import Image modules = { "pil": "PIL._imaging",