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

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

项目:gougo    作者:amaozhao    | 项目源码 | 文件源码
def filters(im, detail=False, sharpen=False, **kwargs):
    """
    Pass the source image through post-processing filters.

    sharpen
        Sharpen the thumbnail image (using the PIL sharpen filter)

    detail
        Add detail to the image, like a mild *sharpen* (using the PIL
        ``detail`` filter).

    """
    if detail:
        im = im.filter(ImageFilter.DETAIL)
    if sharpen:
        im = im.filter(ImageFilter.SHARPEN)
    return im
项目:photoberry    作者:briandilley    | 项目源码 | 文件源码
def create_strip(self, resolution_ratio=None):
        """
        Combines the images in taken_photos into one
        :return: the combined image
        """

        if not resolution_ratio:
            resolution_ratio = self.strip_resolution_ratio

        padding = 40
        photo_width = int(self.photo_resolution[0] * resolution_ratio)
        photo_height = int(self.photo_resolution[1] * resolution_ratio)
        width = (photo_width * 2) + (padding * 4)
        height = (photo_height * self.picture_count) + (padding * (self.picture_count + 1))

        strip = Image.new('RGB', (width, height))
        canvas = ImageDraw.Draw(strip)
        canvas.rectangle((0, 0, width, height), fill=ImageColor.getcolor('#ffffff', 'RGB'))

        for i in range(0, self.picture_count):
            image = Image.open(self.pictures_taken[i])
            image = image.convert(mode='RGB')
            image = image.resize((photo_width, photo_height), resample=Image.LANCZOS)
            strip.paste(image, box=(
                padding,
                padding + (padding * i) + (photo_height * i)
            ))
            strip.paste(image, box=(
                padding + photo_width + padding + padding,
                padding + (padding * i) + (photo_height * i)
            ))
            del image

        strip = strip.transpose(Image.FLIP_LEFT_RIGHT)
        strip = strip.filter(ImageFilter.DETAIL)
        strip = strip.filter(ImageFilter.SHARPEN)

        (handle, file_name) = mkstemp(suffix='.jpg', prefix='photoberry-strip')
        os.close(handle)
        handle = open(file_name, 'wb')
        strip.save(handle, format='jpeg', quality=95, optimize=True)
        handle.close()
        handle.close()
        del strip
        return file_name