From c5b6d7946bf420c5d08ceeab02e576a971598fa4 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Fri, 15 Jan 2021 08:59:48 -0500 Subject: [PATCH] Let the glymur library multiple cpus for decoding. --- CHANGELOG.md | 2 ++ sources/openjpeg/large_image_source_openjpeg/__init__.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6c319637..c526425cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,11 @@ ### Improvements - Better release bioformats resources (#502) - Better handling of tiff files with JPEG compression and RGB colorspace (#503) +- The openjpeg tile source can decode with parallelism (#511) ### Bug Fixes - Harden updates of the item view after making a large image (#508) +- Tiles in an unexpected color mode weren't consistently adjusted (#510) ## Version 1.3.2 diff --git a/sources/openjpeg/large_image_source_openjpeg/__init__.py b/sources/openjpeg/large_image_source_openjpeg/__init__.py index 0f7c54894..dc6e17c36 100644 --- a/sources/openjpeg/large_image_source_openjpeg/__init__.py +++ b/sources/openjpeg/large_image_source_openjpeg/__init__.py @@ -18,6 +18,7 @@ import glymur import math +import multiprocessing import PIL.Image import six import warnings @@ -96,6 +97,7 @@ def __init__(self, path, **kwargs): self._openjpeg = glymur.Jp2k(largeImagePath) except glymur.jp2box.InvalidJp2kError: raise TileSourceException('File cannot be opened via Glymur and OpenJPEG.') + glymur.set_option('lib.num_threads', multiprocessing.cpu_count()) self._openjpegHandles = queue.LifoQueue() for _ in range(self._maxOpenHandles - 1): self._openjpegHandles.put(None)