コード例 #1
0
ファイル: subviews.py プロジェクト: ClameZhang/iDong
def upload(request):
    reqfile = request.FILES['photo']
    image   = image.open(reqfile)

    image.thumbnail((128,128), Image.ANTIALIAS)
    image.save("/home/bing/1.jpeg", "jpeg")
    return HttpResponse("success.")
コード例 #2
0
def upload(request):
    reqfile = request.FILES['photo']
    image = image.open(reqfile)

    image.thumbnail((128, 128), Image.ANTIALIAS)
    image.save("/home/bing/1.jpeg", "jpeg")
    return HttpResponse("success.")
コード例 #3
0
def handler(event):
    if event['thumbnail']:
        #path at which image is situated
        image_path = '/xx/xx/xx'
        #path at which resized image(thumbnail) will be stored.
        resized_path = '/xx/xx/xx'
        with Image.open(image_path) as image:
            image.thumbnail(tuple(x / 2 for x in image.size))
            image.save(resized_path)
    else:
        print('Sorry! No thumbnail found!')
コード例 #4
0
ファイル: py3lock.py プロジェクト: CD2195/arch_linux_configs
def obscure(rects):
    """ Takes an array of rects to obscure from the screenshot. """
    image = Image.open("/tmp/.i3lock.png")

    for rect in sects:
        area = (rect.x, rect.y, rect.x + rect.width, rect.y + rect.height)

        cropped = image.crop(area)
        cropped = obscure_image(cropped)
        image.paste(cropped, area)

    image.save("/tmp/.i3lock.png")
コード例 #5
0
def resize_image(image_path, resized_path):
    with Image.open(image_path) as image:
        image.thumbnail(tuple(x/2 for x in image.size))
        image.save(resized_path)