Python PIL.ImageFilter 模块,FIND_EDGES 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用PIL.ImageFilter.FIND_EDGES

项目:r2-d7    作者:FreakyDug    | 项目源码 | 文件源码
def main():
    if not os.path.exists('emoji'):
        os.mkdir('emoji')

    font = ImageFont.truetype('kimberley bl.ttf', 128)
    for stat, bits in stat_ranges.items():
        numbers, colour = bits
        for number in numbers:
            im = Image.new("RGBA", (300, 300), (255, 255, 255, 0))

            draw = ImageDraw.Draw(im)
            draw.text((0, 0), number, font=font, fill=colour)

            # remove unneccessory whitespaces if needed
            im = im.crop(ImageOps.invert(im.convert('RGB')).getbbox())

            # im = ImageOps.invert(im)
            im.thumbnail(size, Image.ANTIALIAS)

            background = Image.new('RGBA', size, (255, 255, 255, 0))
            background.paste(
                im,
                ((size[0] - im.size[0]) // 2, (size[1] - im.size[1]) // 2))
            # background.paste(
            #     im.filter(ImageFilter.FIND_EDGES).convert('1'),
            #     ((size[0] - im.size[0]) // 2, (size[1] - im.size[1]) // 2))

            # write into file
            number = number.replace('±', '_')
            number = number.replace('+', 'plus')
            background.save("emoji/{}.png".format('{}{}'.format(stat, number)))
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def findedges(message, im):
    """
    Applies a find-edges effect.

    Example::

        /drawtext Hello there! | find edges

    Requires an input image.
    """
    return im.filter(ImageFilter.FIND_EDGES)