Skip to content

Commit 4e29633

Browse files
committed
Issue clearer error if libopenslide is too old
1 parent 356826e commit 4e29633

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

openslide/lowlevel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ def _load_image(buf, size):
123123
# Now load the image as RGBA, undoing premultiplication
124124
return PIL.Image.frombuffer('RGBA', size, buf, 'raw', 'RGBa', 0, 1)
125125

126+
try:
127+
get_version = _func('openslide_get_version', c_char_p, [], None)
128+
except AttributeError:
129+
raise OpenSlideError('OpenSlide >= 3.3.0 required')
130+
126131
can_open = _func('openslide_can_open', c_bool, [c_char_p], None)
127132

128133
open = _func('openslide_open', c_void_p, [c_char_p], _check_open)
@@ -189,5 +194,3 @@ def read_associated_image(slide, name):
189194
buf = (w.value * h.value * c_uint32)()
190195
_read_associated_image(slide, name, buf)
191196
return _load_image(buf, (w.value, h.value))
192-
193-
get_version = _func('openslide_get_version', c_char_p, [], None)

0 commit comments

Comments
 (0)