Exemplo n.º 1
0
from random import random
from zope.component.hooks import getSite
from zope.interface import implements
import os.path


from PIL.ImageFont import _imagingft_not_installed
from PIL.ImageFont import core
if core.__class__ is _imagingft_not_installed:
    FREETYPE_MISSING = (
        'The "_imagingft" C module is not installed, '
        ' which is part of "freetype".'
        ' Install the freetype library and reinstall Pillow with'
        ' freetype support.'
        ' The avatar generation is disabled now.')
    LOGGER.error(FREETYPE_MISSING)
else:
    FREETYPE_MISSING = False


class DefaultAvatarGenerator(object):
    implements(IAvatarGenerator)

    # The resulting image size (square_size * square_size)
    square_size = 220

    def generate(self, userid, output_stream):
        if FREETYPE_MISSING:
            return False
        image = Image.new('RGBA', (self.square_size, self.square_size),
                          self.background_color())
Exemplo n.º 2
0
from Products.CMFCore.utils import getToolByName
from random import random
from zope.component.hooks import getSite
from zope.interface import implements
import os.path

from PIL.ImageFont import _imagingft_not_installed
from PIL.ImageFont import core
if core.__class__ is _imagingft_not_installed:
    FREETYPE_MISSING = (
        'The "_imagingft" C module is not installed, '
        ' which is part of "freetype".'
        ' Install the freetype library and reinstall Pillow with'
        ' freetype support.'
        ' The avatar generation is disabled now.')
    LOGGER.error(FREETYPE_MISSING)
else:
    FREETYPE_MISSING = False


class DefaultAvatarGenerator(object):
    implements(IAvatarGenerator)

    # The resulting image size (square_size * square_size)
    square_size = 220

    def generate(self, userid, output_stream):
        if FREETYPE_MISSING:
            return False
        image = Image.new('RGBA', (self.square_size, self.square_size),
                          self.background_color())