Example #1
0
def instagram_filter(im, filter_):
    buffer = BytesIO()
    im = Image.open(im)
    filter_ = filter_.lower()
    if filter_ == "_1977":
        pilgram._1977(im).save(buffer, format="png")
    elif filter_ == "aden":
        pilgram.aden(im).save(buffer, format="png")
    elif filter_ == "brannan":
        pilgram.brannan(im).save(buffer, format="png")
    elif filter_ == "brooklyn":
        pilgram.brooklyn(im).save(buffer, format="png")
    elif filter_ == "clarendon":
        pilgram.clarendon(im).save(buffer, format="png")
    elif filter_ == "gingham":
        pilgram.gingham(im).save(buffer, format="png")
    elif filter_ == "hudson":
        pilgram.hudson(im).save(buffer, format="png")
    elif filter_ == "inkwell":
        pilgram.inkwell(im).save(buffer, format="png")
    elif filter_ == "earlybird":
        pilgram.earlybird(im).save(buffer, format="png")
    elif filter_ == "kelvin":
        pilgram.kelvin(im).save(buffer, format="png")
    elif filter_ == "lark":
        pilgram.lark(im).save(buffer, format="png")
    elif filter_ == "lofi":
        pilgram.lofi(im).save(buffer, format="png")
    elif filter_ == "maven":
        pilgram.maven(im).save(buffer, format="png")
    elif filter_ == "mayfair":
        pilgram.mayfair(im).save(buffer, format="png")
    elif filter_ == "moon":
        pilgram.moon(im).save(buffer, format="png")
    elif filter_ == "nashville":
        pilgram.nashville(im).save(buffer, format="png")
    elif filter_ == "perpetua":
        pilgram.perpetua(im).save(buffer, format="png")
    elif filter_ == "reyes":
        pilgram.reyes(im).save(buffer, format="png")
    elif filter_ == "rise":
        pilgram.rise(im).save(buffer, format="png")
    elif filter_ == "slumber":
        pilgram.slumber(im).save(buffer, format="png")
    elif filter_ == "stinson":
        pilgram.stinson(im).save(buffer, format="png")
    elif filter_ == "toaster":
        pilgram.toaster(im).save(buffer, format="png")
    elif filter_ == "valencia":
        pilgram.valencia(im).save(buffer, format="png")
    elif filter_ == "walden":
        pilgram.walden(im).save(buffer, format="png")
    elif filter_ == "willow":
        pilgram.willow(im).save(buffer, format="png")
    elif filter_ == "xpro2":
        pilgram.xpro2(im).save(buffer, format="png")
    else:
        return "Nama Filter Belum Tersedia"
    return buffer
Example #2
0
def apply_lofi(image, id):
    result = pilgram.lofi(image)
    BackToSwift().prepare_data(type=ResultType.image.value,
                               node_id=id,
                               data=result,
                               tool_type="pil",
                               extension="jpg")
    return result
def filter_process(filter_no):
    switcher = {
        0: pilgram._1977(im),
        1: pilgram.brannan(im),
        2: pilgram.earlybird(im),
        3: pilgram.hudson(im),
        4: pilgram.inkwell(im),
        5: pilgram.kelvin(im),
        6: pilgram.lofi(im),
        7: pilgram.mayfair(im),
        8: pilgram.nashville(im),
        9: pilgram.rise(im),
        10: pilgram.toaster(im),
        11: pilgram.valencia(im),
        12: pilgram.walden(im),
        13: pilgram.willow(im),
        14: pilgram.xpro2(im),
        15: apply_filter('bt21.jpg', 'amaro')
    }
    return switcher.get(filter_no, "nothing")
Example #4
0
def test_lofi():
    im = util.fill((32, 32), [255] * 3)
    lofi(im)
 elif filter == 'inkwell':
     _path = os.path.join(split_root, filter)
     os.makedirs(_path, exist_ok=True)
     pilgram.inkwell(Image.open(os.path.join(original_images_dir_path, original_image_file))).save(os.path.join(_path, original_image_file))
 elif filter == 'kelvin':
     _path = os.path.join(split_root, filter)
     os.makedirs(_path, exist_ok=True)
     pilgram.kelvin(Image.open(os.path.join(original_images_dir_path, original_image_file))).save(os.path.join(_path, original_image_file))
 elif filter == 'lark':
     _path = os.path.join(split_root, filter)
     os.makedirs(_path, exist_ok=True)
     pilgram.lark(Image.open(os.path.join(original_images_dir_path, original_image_file))).save(os.path.join(_path, original_image_file))
 elif filter == 'lofi':
     _path = os.path.join(split_root, filter)
     os.makedirs(_path, exist_ok=True)
     pilgram.lofi(Image.open(os.path.join(original_images_dir_path, original_image_file))).save(os.path.join(_path, original_image_file))
 elif filter == 'maven':
     _path = os.path.join(split_root, filter)
     os.makedirs(_path, exist_ok=True)
     pilgram.maven(Image.open(os.path.join(original_images_dir_path, original_image_file))).save(os.path.join(_path, original_image_file))
 elif filter == 'mayfair':
     _path = os.path.join(split_root, filter)
     os.makedirs(_path, exist_ok=True)
     pilgram.mayfair(Image.open(os.path.join(original_images_dir_path, original_image_file))).save(os.path.join(_path, original_image_file))
 elif filter == 'moon':
     _path = os.path.join(split_root, filter)
     os.makedirs(_path, exist_ok=True)
     pilgram.moon(Image.open(os.path.join(original_images_dir_path, original_image_file))).save(os.path.join(_path, original_image_file))
 elif filter == 'nashville':
     _path = os.path.join(split_root, filter)
     os.makedirs(_path, exist_ok=True)
Example #6
0
def apply_kelvin(image):
    copyim = Image.fromarray(image)
    filtered = pilgram.lofi(copyim)
    imcv = np.asarray(filtered)[:, :, ::-1].copy()
    return imcv
Example #7
0
def Lofi(image):
    return pilgram.lofi(image)