There's only a need for grayscale images in the frontend, so this conversion to RGB/RGBA is possibly unnecessary:
|
# Convert to RGB if necessary (TIFF might be in different modes) |
|
if img.mode not in ('RGB', 'RGBA'): |
|
if img.mode == 'I;16': |
|
array = np.array(img) |
|
normalized = (array.astype(np.uint16) - array.min()) * 255.0 / (array.max() - array.min()) |
|
img = Image.fromarray(normalized.astype(np.uint8)) |
|
img = img.convert('RGB') |