mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06: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__
|
import __builtin__
|
||||||
builtins = __builtin__
|
builtins = __builtin__
|
||||||
|
|
||||||
from PIL import ImageMode, ImageQt
|
from PIL import ImageMode
|
||||||
from PIL._binary import i8
|
from PIL._binary import i8
|
||||||
from PIL._util import isPath
|
from PIL._util import isPath
|
||||||
from PIL._util import isStringType
|
from PIL._util import isStringType
|
||||||
from PIL._util import deferred_error
|
from PIL._util import deferred_error
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import io
|
import io
|
||||||
|
@ -1937,13 +1936,17 @@ class Image(object):
|
||||||
im = self.im.effect_spread(distance)
|
im = self.im.effect_spread(distance)
|
||||||
return self._new(im)
|
return self._new(im)
|
||||||
|
|
||||||
if ImageQt.qt_is_installed:
|
def toqimage(self):
|
||||||
def toqimage(self):
|
from PIL import ImageQt
|
||||||
return ImageQt.toqimage(self)
|
if not ImageQt.qt_is_installed:
|
||||||
|
raise ImportError("Qt bindings are not installed")
|
||||||
def toqpixmap(self):
|
return ImageQt.toqimage(self)
|
||||||
return ImageQt.toqpixmap(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)
|
return frombuffer(mode, size, obj, "raw", rawmode, 0, 1)
|
||||||
|
|
||||||
|
|
||||||
if ImageQt.qt_is_installed:
|
def fromqimage(im):
|
||||||
from PIL.ImageQt import fromqimage, fromqpixmap
|
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 = {
|
_fromarray_typemap = {
|
||||||
# (shape, typestr) => mode, rawmode
|
# (shape, typestr) => mode, rawmode
|
||||||
# first two members of shape are set to one
|
# first two members of shape are set to one
|
||||||
|
|
Loading…
Reference in New Issue
Block a user