Skip to content

add attrs argument to renderThumbnail() #13

@will-moore

Description

@will-moore

There are cases when you have already loaded the zarr.json or .zattrs for a multiscale image before you want to create a thumbnail:

  • In use ome-zarr.js for renderImage() ome/ome2024-ngff-challenge#93 we load the imgAttrs for zarr v3 data to determine whether the URL is to a multiscales image or bioformats2raw or plate. This gives us the full URL to the image itself (e.g. first image in the plate) as well as the image attrs.
  • In Load 0.6.dev1 schemas from github ome/ome-ngff-validator#48 where we want to show thumbnails for each input image in various coordinateTransformations, we want to check that the image exists by loading the image zarr.json (zarr v3 only for this spec) so that we can show a nice "not found" message instead of a failed thumbnail if the input is not valid.

In such cases, having the attrs in hand allows us to skip the loading of this in renderThumbnail(). This can save us 1 or 2 calls - since renderThumbnail() tries to load both .zattrs and zarr.json as it doesn't know if the URL is for zarr v2 or zarr v3. Having the multiscales attrs can tell us whether we are working with Zarr v2 or v3:

Zarr v2

{ "multiscales": [{"version": "0.4"...}] }

Zarr v3 (complete zarr.json)

{"ome": { "version": "0.5", "multiscales": {}. } } }

This would involve adding an imgAttrs argument at

maxSize: number = 1000

Then the getMultiscaleWithArray() functionality would be split into 2 parts, since the getMultiscale() wouldn't be needed.
The rest of that function, from

const paths: Array<string> = multiscale.datasets.map((d) => d.path);
onwards can be moved to a new function getArrayInfo().

Then, if we already have the imgAttrs, we call getArrayInfo() to return the same as getMultiscaleWithArray() but if we don't have imgAttrs, we call getMultiscaleWithArray() as now, but it calls getMultiscale() and then getArrayInfo().

@lubianat - if you're interested in working on ome-zarr.js, this could be a good start?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions