Python PIL.ImageChops 模块,add() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用PIL.ImageChops.add()

项目:ascii-art-py    作者:blinglnav    | 项目源码 | 文件源码
def do_add(self):
        """usage: add <image:pic1> <image:pic2> <int:offset> <float:scale>

        Pop the two top images, produce the scaled sum with offset.
        """
        from PIL import ImageChops
        image1 = self.do_pop()
        image2 = self.do_pop()
        scale = float(self.do_pop())
        offset = int(self.do_pop())
        self.push(ImageChops.add(image1, image2, scale, offset))
项目:indus-script-ocr    作者:tpsatish95    | 项目源码 | 文件源码
def trim(im):

    bg = Image.new(im.mode, im.size, im.getpixel((0, 0)))
    diff = ImageChops.difference(im, bg)
    diff = ImageChops.add(diff, diff, 2.0, -100)
    bbox = diff.getbbox()
    if bbox:
        return im.crop(bbox)
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def trim(im):
    bg = Image.new(im.mode, im.size, im.getpixel((0, 0)))
    diff = ImageChops.difference(im, bg)
    diff = ImageChops.add(diff, diff, 2.0, -100)
    bbox = diff.getbbox()
    if bbox:
        return im.crop(bbox)
    else:
        return im
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def setup():
    config.add(api_key)
    config.add(page_load_timeout)

    if not api_key():
        raise PluginSetupError("This plugin requires an API key to be chosen.")

    app.add(handle)
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def trim_whitespace(im):
    bg = Image.new(im.mode, im.size, im.getpixel((0, 0)))
    diff = ImageChops.difference(im, bg)
    diff = ImageChops.add(diff, diff, 2.0, -100)
    bbox = diff.getbbox()
    if bbox:
        return im.crop(bbox)
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def setup():
    commands.add(pie)
    commands.add(bar)
    commands.add(histogram)
    commands.add(latex)
项目:bittray    作者:nkuttler    | 项目源码 | 文件源码
def trim(self, im):
        """
        Auto-trim
        """
        bg = Image.new(im.mode, im.size, im.getpixel((0, 0)))
        diff = ImageChops.difference(im, bg)
        diff = ImageChops.add(diff, diff, 2.0, -100)
        bbox = diff.getbbox()
        if bbox:
            return im.crop(bbox)
项目:netstalking-telegram-bot    作者:pantyusha    | 项目源码 | 文件源码
def trim(im):
    pixel = (255, 255, 255)  # ????????????? ?? ????? ????
    # pixel = im.getpixel((0,0))  # ????????????? ?? ??????? ? ?????? ???????? ????
    bg = Image.new(im.mode, im.size, pixel)
    diff = ImageChops.difference(im, bg)
    diff = ImageChops.add(diff, diff, 2.0, -100)
    bbox = diff.getbbox()
    logger.info(bbox)
    if bbox:
        return im.crop(bbox)
    else:
        return im
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def pie(message):
    """
    Generate a pie graph. To specify the parts of the pie, make a
    list separated by new lines, semi-colons or commas where each
    list entry has a percentage in it (if there is more than one, the
    first percentage is used).

    To specify a graph title, don't provide a percentage for one of the
    list items.

    Example::

        /pie Materials, 40% Glass, 22%

    The percentages do not need to add up to 100%. If they do not, then
    the percentage values will be normalized so that they do add up to 100%.

    """
    title, labels, data = extract_data(message.content, pattern=PERCENTAGE_PATTERN, normalize=True)

    def execute():
        with lock:
            plt.figure(1, figsize=(5, 5))
            ax = plt.axes([0.1, 0.1, 0.4, 0.4])

            plt.pie(data, labels=labels, autopct='%1.0f%%', startangle=90)

            if title:
                plt.title(title)

            prop = fm.FontProperties(fname=font_path, size=11)
            for text in ax.texts:
                text.set_fontproperties(prop)

            buf = io.BytesIO()
            plt.savefig(buf, bbox_inches='tight', transparent=False, pad_inches=0.1)

            plt.clf()
        return buf

    buf = await asyncio.get_event_loop().run_in_executor(None, execute)

    return Response("", attachments=[MemoryAttachment(buf, "graph.png", "image/png")])