Skip to content

Commit 9026587

Browse files
authored
Merge pull request #201 from herrmannlab/make_pylibjpeg-libjpeg_optional
Make pylibjpeg-libjpeg optional
2 parents 14365c3 + 7e08517 commit 9026587

File tree

7 files changed

+372
-318
lines changed

7 files changed

+372
-318
lines changed

.github/workflows/run_unit_tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
python-version: ["3.7", "3.8", "3.9", "3.10"]
19+
dependencies: [".", "'.[libjpeg]'"]
1920

2021
steps:
2122
- uses: actions/checkout@v2
@@ -27,7 +28,7 @@ jobs:
2728
run: |
2829
python -m pip install --upgrade pip setuptools
2930
pip install -r requirements_test.txt
30-
pip install .
31+
pip install ${{ matrix.dependencies }}
3132
- name: Lint with flake8
3233
run: |
3334
flake8 --exclude='bin,build,.eggs,src/highdicom/_*'

docs/installation.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Installation guide
88
Requirements
99
------------
1010

11-
* `Python <https://www.python.org/>`_ (version 3.5 or higher)
11+
* `Python <https://www.python.org/>`_ (version 3.6 or higher)
1212
* Python package manager `pip <https://pip.pypa.io/en/stable/>`_
1313

1414
.. _installation:
@@ -22,7 +22,22 @@ Pre-build package available at PyPi:
2222
2323
pip install highdicom
2424
25-
Source code available at Github:
25+
The library relies on the underlying ``pydicom`` package for decoding of pixel
26+
data, which internally delegates the task to either the ``pillow`` or the
27+
``pylibjpeg`` packages. Since ``pillow`` is a dependency of *highdicom* and
28+
will automatically be installed, some transfer syntax can thus be readily
29+
decoded and encoded (baseline JPEG, JPEG-2000, JPEG-LS). Support for additional
30+
transfer syntaxes (e.g., lossless JPEG) requires installation of the
31+
``pylibjpeg`` package as well as the ``pylibjpeg-libjpeg`` and
32+
``pylibjpeg-openjpeg`` packages. Since ``pylibjpeg-libjpeg`` is licensed under
33+
a copyleft GPL v3 license, it is not installed by default when you install
34+
*highdicom*. To install the ``pylibjpeg`` packages along with *highdicom*, use
35+
36+
.. code-block:: none
37+
38+
pip install highdicom[libjpeg]
39+
40+
Install directly from source code (available on Github):
2641

2742
.. code-block:: none
2843

setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ def get_version():
5555
'numpy>=1.19',
5656
'pillow>=8.3',
5757
'pillow-jpls>=1.0',
58-
'pylibjpeg>=1.4',
59-
'pylibjpeg-libjpeg>=1.3',
60-
'pylibjpeg-openjpeg>=1.2',
6158
],
59+
extras_requires={
60+
'libjpeg': [
61+
'pylibjpeg>=1.4',
62+
'pylibjpeg-libjpeg>=1.3',
63+
'pylibjpeg-openjpeg>=1.2'
64+
],
65+
},
6266
)

tests/test_frame.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def test_jpeg2000_monochrome(self):
215215
np.testing.assert_array_equal(frame, decoded_frame)
216216

217217
def test_jpegls_rgb(self):
218+
pytest.importorskip("libjpeg")
218219
bits_allocated = 8
219220
frame = np.ones((16, 32, 3), dtype=np.dtype(f'uint{bits_allocated}'))
220221
frame *= 255
@@ -244,6 +245,7 @@ def test_jpegls_rgb(self):
244245
np.testing.assert_array_equal(frame, decoded_frame)
245246

246247
def test_jpegls_monochrome(self):
248+
pytest.importorskip("libjpeg")
247249
bits_allocated = 16
248250
frame = np.zeros((16, 32), dtype=np.dtype(f'uint{bits_allocated}'))
249251
compressed_frame = encode_frame(

tests/test_pm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def test_multi_frame_sm_image_ushort_encapsulated_jpeg2000(self):
584584
assert np.array_equal(pmap.pixel_array, pixel_array)
585585

586586
def test_multi_frame_sm_image_ushort_encapsulated_jpegls(self):
587+
pytest.importorskip("libjpeg")
587588
pixel_array = np.random.randint(
588589
low=0,
589590
high=2**8,

tests/test_sc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ def test_rgb_jpeg2000(self):
428428
)
429429

430430
def test_monochrome_jpegls(self):
431+
pytest.importorskip("libjpeg")
431432
bits_allocated = 16
432433
photometric_interpretation = 'MONOCHROME2'
433434
coordinate_system = 'PATIENT'
@@ -455,6 +456,7 @@ def test_monochrome_jpegls(self):
455456
)
456457

457458
def test_rgb_jpegls(self):
459+
pytest.importorskip("libjpeg")
458460
bits_allocated = 8
459461
photometric_interpretation = 'YBR_FULL'
460462
coordinate_system = 'PATIENT'

0 commit comments

Comments
 (0)