Skip to content

Commit

Permalink
try to support older versions of PIL (Debian Wheezy..)
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@13184 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 3, 2016
1 parent fcf5f44 commit d0e3e45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/xpra/codecs/pillow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import os
import logging
from xpra.log import Logger

PIL_DEBUG = os.environ.get("XPRA_PIL_DEBUG", "0")=="1"
if PIL_DEBUG:
from xpra.log import Logger
log = Logger("encoder", "pillow")
log.info("enabling PIL.DEBUG")
level = logging.DEBUG
Expand All @@ -23,8 +24,15 @@
import PIL #@UnresolvedImport
from PIL import Image #@UnresolvedImport
assert PIL is not None and Image is not None, "failed to load Pillow"
PIL_VERSION = PIL.PILLOW_VERSION
try:
PIL_VERSION = PIL.PILLOW_VERSION
except:
PIL_VERSION = Image.VERSION
if hasattr(Image, "DEBUG"):
#for older versions (pre 3.0), use Image.DEBUG flag:
Image.DEBUG = int(PIL_DEBUG)
if PIL_VERSION<'2':
log = Logger("encoder", "pillow")
log.warn("Warning: your version of Python Imaging Library is well out of date")
log.warn(" version %s is not supported, your mileage may vary", PIL_VERSION)
Image.init()
3 changes: 2 additions & 1 deletion src/xpra/codecs/pillow/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import PIL #@UnresolvedImport
from PIL import Image #@UnresolvedImport
from xpra.codecs.pillow import PIL_VERSION


def get_version():
return PIL.PILLOW_VERSION
return PIL_VERSION

def get_type():
return "pillow"
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/codecs/pillow/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

import PIL #@UnresolvedImport
from PIL import Image #@UnresolvedImport
PIL_VERSION = PIL.PILLOW_VERSION
from xpra.codecs.pillow import PIL_VERSION
PIL_can_optimize = PIL_VERSION and PIL_VERSION>="2.2"

SAVE_TO_FILE = os.environ.get("XPRA_SAVE_TO_FILE")


def get_version():
return PIL.PILLOW_VERSION
return PIL_VERSION

def get_type():
return "pillow"
Expand Down

0 comments on commit d0e3e45

Please sign in to comment.