mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Do not import ImageQt until it is requested
This commit is contained in:
parent
33d51d4255
commit
c644bf9455
32
PIL/Image.py
32
PIL/Image.py
|
@ -101,13 +101,12 @@ except ImportError:
|
|||
import __builtin__
|
||||
builtins = __builtin__
|
||||
|
||||
from PIL import ImageMode, ImageQt
|
||||
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
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import io
|
||||
|
@ -1937,13 +1936,17 @@ class Image(object):
|
|||
im = self.im.effect_spread(distance)
|
||||
return self._new(im)
|
||||
|
||||
if ImageQt.qt_is_installed:
|
||||
def toqimage(self):
|
||||
return ImageQt.toqimage(self)
|
||||
|
||||
def toqpixmap(self):
|
||||
return ImageQt.toqpixmap(self)
|
||||
def toqimage(self):
|
||||
from PIL import ImageQt
|
||||
if not ImageQt.qt_is_installed:
|
||||
raise ImportError("Qt bindings are not installed")
|
||||
return ImageQt.toqimage(self)
|
||||
|
||||
def toqpixmap(self):
|
||||
from PIL import ImageQt
|
||||
if not ImageQt.qt_is_installed:
|
||||
raise ImportError("Qt bindings are not installed")
|
||||
return ImageQt.toqpixmap(self)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
@ -2195,10 +2198,19 @@ def fromarray(obj, mode=None):
|
|||
return frombuffer(mode, size, obj, "raw", rawmode, 0, 1)
|
||||
|
||||
|
||||
if ImageQt.qt_is_installed:
|
||||
from PIL.ImageQt import fromqimage, fromqpixmap
|
||||
def fromqimage(im):
|
||||
from PIL import ImageQt
|
||||
if not ImageQt.qt_is_installed:
|
||||
raise ImportError("Qt bindings are not installed")
|
||||
return ImageQt.fromqimage(im)
|
||||
|
||||
|
||||
def fromqpixmap(im):
|
||||
from PIL import ImageQt
|
||||
if not ImageQt.qt_is_installed:
|
||||
raise ImportError("Qt bindings are not installed")
|
||||
return ImageQt.fromqpixmap(im)
|
||||
|
||||
_fromarray_typemap = {
|
||||
# (shape, typestr) => mode, rawmode
|
||||
# first two members of shape are set to one
|
||||
|
|
Loading…
Reference in New Issue
Block a user