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.")
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.")
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!')
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")
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)