Пример #1
0
def dither(i):
    """ Take an instance of single-channel PIL.Image, dither and return
    """
    assert i.mode == "L"
    s = atk.atk(i.size[0], i.size[1], i.tostring())
    o = PIL.Image.fromstring("L", i.size, s)
    return o
Пример #2
0
def dither_atk(img):

    img = img.convert('L')
    tmp = atk.atk(img.size[0], img.size[1], img.tostring())
    new = Image.fromstring('L', img.size, tmp)

    return new.convert('RGBA')
def dither_atk(src_path, dest_path, mime_type):

    import atk
    img = Image.open(src_path)
    img = img.convert('L')
    sz = img.size
    
    tmp = atk.atk(sz[0], sz[1], img.tostring())
    new = Image.fromstring('L', sz, tmp)
    
    new = img.convert('1')
    new.save(dest_path, mime_type)
    return True
def make_dithered(src, dest):

    if os.path.exists(dest):
        return True

    logging.info("make %s" % dest)

    img = Image.open(src)
    img = img.convert('L')
    sz = img.size

    tmp = atk.atk(sz[0], sz[1], img.tostring())
    new = Image.fromstring('L', sz, tmp)

    new = img.convert('1')
    new.save(dest)
    
    return os.path.exists(dest)