2012-11-06 04:34:32 +00:00
|
|
|
# flake8: noqa
|
|
|
|
|
|
2009-01-08 21:11:15 +00:00
|
|
|
# Required PIL classes may or may not be available from the root namespace
|
|
|
|
|
# depending on the installation method used.
|
|
|
|
|
try:
|
2011-11-16 04:42:43 +00:00
|
|
|
from PIL import Image, ImageColor, ImageChops, ImageEnhance, ImageFile, \
|
|
|
|
|
ImageFilter, ImageDraw, ImageStat
|
2009-01-08 21:11:15 +00:00
|
|
|
except ImportError:
|
|
|
|
|
try:
|
2011-10-13 05:35:16 +00:00
|
|
|
import Image
|
|
|
|
|
import ImageColor
|
2011-11-09 21:23:04 +00:00
|
|
|
import ImageChops
|
2011-10-13 05:35:16 +00:00
|
|
|
import ImageEnhance
|
|
|
|
|
import ImageFile
|
|
|
|
|
import ImageFilter
|
2011-11-16 04:42:43 +00:00
|
|
|
import ImageDraw
|
|
|
|
|
import ImageStat
|
2009-01-08 21:11:15 +00:00
|
|
|
except ImportError:
|
2009-12-19 16:01:54 +00:00
|
|
|
raise ImportError('ImageKit was unable to import the Python Imaging Library. Please confirm it`s installed and available on your current Python path.')
|
2012-05-12 19:45:08 +00:00
|
|
|
|
|
|
|
|
try:
|
2013-08-19 18:27:50 +00:00
|
|
|
from io import BytesIO as StringIO
|
|
|
|
|
except:
|
|
|
|
|
try:
|
|
|
|
|
from cStringIO import StringIO
|
|
|
|
|
except ImportError:
|
|
|
|
|
from StringIO import StringIO
|
2013-05-20 23:18:35 +00:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from logging import NullHandler
|
|
|
|
|
except ImportError:
|
|
|
|
|
from logging import Handler
|
|
|
|
|
|
|
|
|
|
class NullHandler(Handler):
|
|
|
|
|
def emit(self, record):
|
|
|
|
|
pass
|
2013-08-19 18:27:50 +00:00
|
|
|
|
|
|
|
|
# Try to import `force_text` available from Django 1.5
|
|
|
|
|
# This function will replace `unicode` used in the code
|
|
|
|
|
# If Django version is under 1.5 then use `force_unicde`
|
|
|
|
|
# It is used for compatibility between Python 2 and Python 3
|
|
|
|
|
try:
|
2013-12-14 18:02:21 +00:00
|
|
|
from django.utils.encoding import force_text, force_bytes, smart_text
|
2013-08-19 18:27:50 +00:00
|
|
|
except ImportError:
|
|
|
|
|
# Django < 1.5
|
2013-12-14 18:02:21 +00:00
|
|
|
from django.utils.encoding import (force_unicode as force_text,
|
|
|
|
|
smart_str as force_bytes,
|
|
|
|
|
smart_unicode as smart_text)
|
2013-08-19 18:27:50 +00:00
|
|
|
|
2013-12-14 18:02:21 +00:00
|
|
|
__all__ = ['Image', 'ImageColor', 'ImageChops', 'ImageEnhance', 'ImageFile',
|
|
|
|
|
'ImageFilter', 'ImageDraw', 'ImageStat', 'StringIO', 'NullHandler',
|
|
|
|
|
'force_text', 'force_bytes', 'smart_text']
|