Skip to content

Commit

Permalink
Revert changes to rendering engine usage for detecting pyramids
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Mar 21, 2024
1 parent 8a41f2f commit ff4f516
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions omeroweb/webgateway/marshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,46 @@ def imageMarshal(image, key=None, request=None):
"canLink": image.canLink(),
},
}
try:
reOK = image._prepareRenderingEngine()
if not reOK:
logger.debug("Failed to prepare Rendering Engine for imageMarshal")
return rv
except omero.ConcurrencyException as ce:
backOff = ce.backOff
rv = {"ConcurrencyException": {"backOff": backOff}}
return rv
except Exception as ex: # Handle everything else.
rv["Exception"] = ex.message
logger.error(traceback.format_exc())
return rv # Return what we have already, in case it's useful

# big images
levels = image._re.getResolutionLevels()
tiles = levels > 1
rv["tiles"] = tiles
if tiles:
width, height = image._re.getTileSize()
zoomLevelScaling = image.getZoomLevelScaling()

rv.update({"tile_size": {"width": width, "height": height}, "levels": levels})
if zoomLevelScaling is not None:
rv["zoomLevelScaling"] = zoomLevelScaling

nominalMagnification = (
image.getObjectiveSettings() is not None
and image.getObjectiveSettings().getObjective().getNominalMagnification()
or None
)

if nominalMagnification is not None:
rv.update({"nominalMagnification": nominalMagnification})

try:
server_settings = request.session.get("server_settings", {}).get("viewer", {})
except Exception:
server_settings = {}
init_zoom = server_settings.get("initial_zoom_level", 0)
if init_zoom < 0:
init_zoom = levels + init_zoom

interpolate = server_settings.get("interpolate_pixels", True)

try:
Expand Down Expand Up @@ -315,6 +340,10 @@ def pixel_size_in_microns(method):
},
}
)
if init_zoom is not None:
rv["init_zoom"] = init_zoom
if nominalMagnification is not None:
rv.update({"nominalMagnification": nominalMagnification})

rdef = get_rendering_def(image, rv)
if not rdef:
Expand Down Expand Up @@ -344,34 +373,10 @@ def pixel_size_in_microns(method):
"defaultT": 0,
"invertAxis": image.isInvertedAxis(),
}

except AttributeError:
# Why do we do raise just for this exception?!
rv = None
raise

# If image is big - need to load RE to get resolution levels
# NB: some small images like OME-Zarr can have pyramids
# but these will be ignored
if not image.requiresPixelsPyramid():
rv["tiles"] = False
else:
if load_re(image, rv):
levels = image._re.getResolutionLevels()
tiles = levels > 1
rv["tiles"] = tiles
if tiles:
width, height = image._re.getTileSize()
zoomLevelScaling = image.getZoomLevelScaling()
rv.update(
{"tile_size": {"width": width, "height": height}, "levels": levels}
)
if zoomLevelScaling is not None:
rv["zoomLevelScaling"] = zoomLevelScaling
if init_zoom < 0:
init_zoom = levels + init_zoom
rv["init_zoom"] = init_zoom

if key is not None and rv is not None:
for k in key.split("."):
rv = rv.get(k, {})
Expand Down

0 comments on commit ff4f516

Please sign in to comment.