示例#1
0
def show_associated(path: Path = Depends(imagepath_parameter)):
    """
    Get associated file info
    """
    original = path.get_original()
    check_representation_existence(original)
    return response_list(AssociatedInfo.from_image(original))
示例#2
0
def export_upload(
        background: BackgroundTasks,
        path: Path = Depends(imagepath_parameter),
):
    """
    Export the upload representation of an image.
    """
    image = path.get_original()
    check_representation_existence(image)

    upload_file = image.get_upload().resolve()
    media_type = image.media_type
    if upload_file.is_dir():
        # if archive has been deleted
        tmp_export = Path(f"/tmp/{unique_name_generator()}")
        make_zip_archive(tmp_export, upload_file)

        def cleanup(tmp):
            tmp.unlink(missing_ok=True)

        background.add_task(cleanup, tmp_export)
        upload_file = tmp_export
        media_type = "application/zip"

    return FileResponse(upload_file, media_type=media_type, filename=path.name)
示例#3
0
def show_instrument(path: Path = Depends(imagepath_parameter)):
    """
    Get image instrument info
    """
    original = path.get_original()
    check_representation_existence(original)
    return InstrumentInfo.from_image(original)
示例#4
0
def show_normalized_pyramid(path: Path = Depends(imagepath_parameter)):
    """
    Get image normalized pyramid
    """
    original = path.get_original()
    check_representation_existence(original)
    return PyramidInfo.from_pyramid(original.normalized_pyramid)
示例#5
0
def show_channels(path: Path = Depends(imagepath_parameter)):
    """
    Get image channel info
    """
    original = path.get_original()
    check_representation_existence(original)
    return response_list(ChannelsInfo.from_image(original))
示例#6
0
def show_image(path: Path = Depends(imagepath_parameter)):
    """
    Get standard image info
    """
    original = path.get_original()
    check_representation_existence(original)
    return ImageInfo.from_image(original)
示例#7
0
def show_metadata(path: Path = Depends(imagepath_parameter)):
    """
    Get image metadata
    """
    original = path.get_original()
    check_representation_existence(original)

    store = original.raw_metadata
    return response_list([Metadata.from_metadata(md) for md in store.values()])
示例#8
0
def show_metadata_annotations(path: Path = Depends(imagepath_parameter)):
    """
    Get image annotation metadata
    """
    original = path.get_original()
    check_representation_existence(original)
    return response_list([
        MetadataAnnotation.from_metadata_annotation(a)
        for a in original.annotations
    ])
示例#9
0
def show_info(path: Path = Depends(imagepath_parameter)):
    """
    Get all image info
    """
    original = path.get_original()
    check_representation_existence(original)
    data = dict()
    data["image"] = ImageInfo.from_image(original)
    data["instrument"] = InstrumentInfo.from_image(original)
    data["associated"] = AssociatedInfo.from_image(original)
    data["channels"] = ChannelsInfo.from_image(original)
    data["representations"] = [
        RepresentationInfo.from_path(rpr)
        for rpr in original.get_representations()
    ]
    return data