Skip to content

Commit 75d8f01

Browse files
authored
Don't perform any colour transformations with decode_pixel_data() v2 (#63)
1 parent b01dbdd commit 75d8f01

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

docs/changes/v2.0.0.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
2.0.0
44
=====
55

6-
Changes
7-
.......
8-
96
* Drop support for Python 3.7
107
* Add supports for Python 3.11 and 3.12
118
* Switched packaging and build to ``pyproject.toml``
129
* Added type hints
1310
* Added support for version 2 of the pixel data decoding interface
1411
* Removed ``utils.reconstruct()``
12+
13+
14+
2.0.1
15+
=====
16+
17+
* Don't apply any colour transformations when using ``decode_pixel_data()``

lib/interface/decode.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ std::string Decode(
4040
int outLength
4141
Expected length of the output array
4242
int colourTransform
43-
JPGFLAG_MATRIX_COLORTRANSFORMATION_NONE 0
44-
JPGFLAG_MATRIX_COLORTRANSFORMATION_YCBCR 1
45-
JPGFLAG_MATRIX_COLORTRANSFORMATION_LSRCT 2
46-
JPGFLAG_MATRIX_COLORTRANSFORMATION_RCT 2
47-
JPGFLAG_MATRIX_COLORTRANSFORMATION_FREEFORM 3
43+
The colour transform that's been applied prior to encoding, one of:
44+
45+
* JPGFLAG_MATRIX_COLORTRANSFORMATION_NONE 0
46+
* JPGFLAG_MATRIX_COLORTRANSFORMATION_YCBCR 1
47+
* JPGFLAG_MATRIX_COLORTRANSFORMATION_LSRCT 2
48+
* JPGFLAG_MATRIX_COLORTRANSFORMATION_RCT 2
49+
* JPGFLAG_MATRIX_COLORTRANSFORMATION_FREEFORM 3
4850
4951
*/
5052
// Check valid value

libjpeg/tests/test_handler.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ def test_invalid_colour_transform(self, add_invalid_colour):
7878
with pytest.raises(RuntimeError, match=msg):
7979
decode(data, -1)
8080

81-
with pytest.raises(RuntimeError, match=msg):
82-
decode_pixel_data(
83-
data,
84-
photometric_interpretation="INVALID",
85-
version=2,
86-
)
87-
8881

8982
# ISO/IEC 10918 JPEG
9083
@pytest.mark.skipif(not HAS_PYDICOM, reason="No dependencies")

libjpeg/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,7 @@ def decode_pixel_data(
210210
return decode(src, transform, reshape=False)
211211

212212
# Version 2
213-
photometric_interpretation = kwargs.get("photometric_interpretation", None)
214-
colour_transform = COLOURSPACE.get(photometric_interpretation, 0)
215-
216-
status, out, params = _libjpeg.decode(src, colour_transform, as_array=False)
213+
status, out, params = _libjpeg.decode(src, colourspace=0, as_array=False)
217214
status = status.decode("utf-8")
218215
code, msg = status.split("::::")
219216
code = int(code)

0 commit comments

Comments
 (0)