Merge branch 'thumbnails-in-scan-tab' into 'v3'
Thumbnails and accurate durations in scan-list tab See merge request openflexure/openflexure-microscope-server!250
This commit is contained in:
commit
88f72caed5
5 changed files with 104 additions and 15 deletions
|
|
@ -99,7 +99,10 @@ class ScanInfo(BaseModel):
|
|||
number_of_images: int
|
||||
|
||||
|
||||
DOWNLOADABLE_SCAN_FILES = ("images.zip",)
|
||||
DOWNLOADABLE_SCAN_FILES = (
|
||||
"images.zip",
|
||||
"stitched_thumbnail.jpg",
|
||||
)
|
||||
|
||||
JPEGBlob = blob_type("image/jpeg")
|
||||
ZipBlob = blob_type("application/zip")
|
||||
|
|
@ -714,6 +717,29 @@ class SmartScanThing(Thing):
|
|||
except SubprocessError as e:
|
||||
self._scan_logger.error(f"Stitching failed: {e}", exc_info=e)
|
||||
|
||||
@fastapi_endpoint(
|
||||
"get",
|
||||
"scans/stitched_thumbnail.jpg",
|
||||
responses={
|
||||
200: {
|
||||
"description": "A thumbnail-quality stitched image",
|
||||
"content": {"image/jpeg": {}},
|
||||
},
|
||||
404: {"description": "File not found"},
|
||||
},
|
||||
)
|
||||
def get_scan_thumbnail(self, scan_name: str) -> FileResponse:
|
||||
"""Retrieve a file from a scan.
|
||||
|
||||
This endpoint allows files to be downloaded from a scan.
|
||||
"""
|
||||
path = os.path.join(
|
||||
self.images_dir_for_scan(scan_name), "stitched_thumbnail.jpg"
|
||||
)
|
||||
if not os.path.isfile(path):
|
||||
raise HTTPException(404, "File not found")
|
||||
return FileResponse(path)
|
||||
|
||||
@_scan_running
|
||||
def _capture_and_save(
|
||||
self,
|
||||
|
|
@ -861,11 +887,12 @@ class SmartScanThing(Thing):
|
|||
number_of_images = len(os.listdir(images_folder))
|
||||
else:
|
||||
number_of_images = 0
|
||||
modified = max(os.stat(root).st_mtime for root, _, _ in os.walk(path))
|
||||
scans.append(
|
||||
ScanInfo(
|
||||
name=f,
|
||||
created=os.path.getctime(path),
|
||||
modified=os.path.getmtime(path),
|
||||
modified=modified,
|
||||
number_of_images=number_of_images,
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue