Esempio n. 1
0
File: app.py Progetto: LouisK130/oii
def serve_image(width=None,pid=None):
    hit, img = pid2image(pid)
    if width is not None:
        (h,w) = img.shape[:2]
        height = int(1. * width / w * h)
        img = resize(img,(height,width))
    return image_response(img, pid)
Esempio n. 2
0
def pid2image(pid='',params=[]):
    for root in ROOTS:
        for s in R().find_file(pid=pid,root=root):
            path = s['file'] # actual path to file
            tags = parse_tags(s.get('tags',None))
            image = imread(path) # read image data
            image = transform_image(image, params, tags)
            # use a fake filename so image_response
            # can guess correct MIME type
            fake_filename = 'i.%s' % s['ext']
            return image_response(image, fake_filename)
    # didn't find anything
    abort(404)