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)
def get_img(hit): if hit is None: raise Exception('Not found') img = imread(hit.value) try: if hit.product == 'redcyan': return redcyan(rgb2gray(img),None,True) if hit.variant is None: hit.variant = hit.default_variant if hit.variant == 'L': return get_L(img) elif hit.variant == 'R': return get_R(img) except AttributeError: pass return img