@@ -81,15 +81,17 @@ def display(
81
81
base = url (f"plugins/{ name } " )
82
82
context = {
83
83
"href" : f"{ base } /display_one/{ path } " ,
84
- "pages " : arr .shape [ 0 ] ,
84
+ "shape " : arr .shape ,
85
85
}
86
86
return templates .TemplateResponse (request , "display.html" , context = context )
87
87
88
88
89
- async def __get_image (path , user , i ):
89
+ async def __get_image (path , user , ndim , i ):
90
90
# Alternatively, call abspath_and_dataprep with the corresponding slice to download data async
91
91
array = await get_container (path , user )
92
- content = array [i ]
92
+ index = [slice (None ) for x in array .shape ]
93
+ index [ndim ] = slice (i , i + 1 , 1 )
94
+ content = array [tuple (index )].squeeze ()
93
95
return PIL .Image .fromarray (content )
94
96
95
97
@@ -99,13 +101,14 @@ async def display_one(
99
101
# Path parameters
100
102
path : pathlib .Path ,
101
103
# Query parameters
102
- i : int ,
104
+ ndim : int = 0 ,
105
+ i : int = 0 ,
103
106
user : db .User = Depends (optional_user ),
104
107
):
105
- img = await __get_image (path , user , i )
108
+ img = await __get_image (path , user , ndim , i )
106
109
107
110
base = url (f"plugins/{ name } " )
108
- src = f"{ base } /image/{ path } ?{ i = } "
111
+ src = f"{ base } /image/{ path } ?{ ndim = } & { i = } "
109
112
110
113
width = 768 # Max size
111
114
links = []
@@ -129,11 +132,12 @@ async def image_file(
129
132
# Path parameters
130
133
path : pathlib .Path ,
131
134
# Query parameters
135
+ ndim : int ,
132
136
i : int ,
133
137
width : int | None = None ,
134
138
user : db .User = Depends (optional_user ),
135
139
):
136
- img = await __get_image (path , user , i )
140
+ img = await __get_image (path , user , ndim , i )
137
141
img_file = resize_image (img , width )
138
142
139
143
def iterfile ():
0 commit comments