imageio 2.34.2__tar.gz → 2.35.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. {imageio-2.34.2/imageio.egg-info → imageio-2.35.1}/PKG-INFO +3 -2
  2. {imageio-2.34.2 → imageio-2.35.1}/docs/conf.py +6 -7
  3. {imageio-2.34.2 → imageio-2.35.1}/docs/reference/index.rst +1 -0
  4. {imageio-2.34.2 → imageio-2.35.1}/imageio/__init__.py +1 -1
  5. {imageio-2.34.2 → imageio-2.35.1}/imageio/config/extensions.py +2 -2
  6. {imageio-2.34.2 → imageio-2.35.1}/imageio/config/plugins.py +3 -1
  7. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/imopen.pyi +10 -0
  8. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/pyav.py +7 -0
  9. imageio-2.35.1/imageio/plugins/rawpy.py +191 -0
  10. {imageio-2.34.2 → imageio-2.35.1/imageio.egg-info}/PKG-INFO +3 -2
  11. {imageio-2.34.2 → imageio-2.35.1}/imageio.egg-info/SOURCES.txt +2 -0
  12. {imageio-2.34.2 → imageio-2.35.1}/imageio.egg-info/requires.txt +6 -2
  13. {imageio-2.34.2 → imageio-2.35.1}/setup.py +6 -1
  14. {imageio-2.34.2 → imageio-2.35.1}/tests/test_pillow.py +3 -0
  15. {imageio-2.34.2 → imageio-2.35.1}/tests/test_pyav.py +31 -0
  16. imageio-2.35.1/tests/test_rawpy.py +81 -0
  17. {imageio-2.34.2 → imageio-2.35.1}/CONTRIBUTORS.txt +0 -0
  18. {imageio-2.34.2 → imageio-2.35.1}/LICENSE +0 -0
  19. {imageio-2.34.2 → imageio-2.35.1}/MANIFEST.in +0 -0
  20. {imageio-2.34.2 → imageio-2.35.1}/README.md +0 -0
  21. {imageio-2.34.2 → imageio-2.35.1}/docs/Makefile +0 -0
  22. {imageio-2.34.2 → imageio-2.35.1}/docs/_static/imageio_logo.png +0 -0
  23. {imageio-2.34.2 → imageio-2.35.1}/docs/_templates/better_class.rst +0 -0
  24. {imageio-2.34.2 → imageio-2.35.1}/docs/_templates/formats.rst.template +0 -0
  25. {imageio-2.34.2 → imageio-2.35.1}/docs/_templates/plugin.rst +0 -0
  26. {imageio-2.34.2 → imageio-2.35.1}/docs/development/index.rst +0 -0
  27. {imageio-2.34.2 → imageio-2.35.1}/docs/development/plugins.rst +0 -0
  28. {imageio-2.34.2 → imageio-2.35.1}/docs/examples.rst +0 -0
  29. {imageio-2.34.2 → imageio-2.35.1}/docs/formats/formats_by_plugin.rst +0 -0
  30. {imageio-2.34.2 → imageio-2.35.1}/docs/formats/index.rst +0 -0
  31. {imageio-2.34.2 → imageio-2.35.1}/docs/formats/video_formats.rst +0 -0
  32. {imageio-2.34.2 → imageio-2.35.1}/docs/imageio_ext.py +0 -0
  33. {imageio-2.34.2 → imageio-2.35.1}/docs/index.rst +0 -0
  34. {imageio-2.34.2 → imageio-2.35.1}/docs/make.bat +0 -0
  35. {imageio-2.34.2 → imageio-2.35.1}/docs/reference/core_v3.rst +0 -0
  36. {imageio-2.34.2 → imageio-2.35.1}/docs/reference/userapi.rst +0 -0
  37. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/cmdlinescripts.rst +0 -0
  38. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/drop27.rst +0 -0
  39. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/envvariables.rst +0 -0
  40. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/freezing.rst +0 -0
  41. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/index.rst +0 -0
  42. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/installation.rst +0 -0
  43. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/overview.rst +0 -0
  44. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/requests.rst +0 -0
  45. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/scipy.rst +0 -0
  46. {imageio-2.34.2 → imageio-2.35.1}/docs/user_guide/standardimages.rst +0 -0
  47. {imageio-2.34.2 → imageio-2.35.1}/imageio/__main__.py +0 -0
  48. {imageio-2.34.2 → imageio-2.35.1}/imageio/config/__init__.py +0 -0
  49. {imageio-2.34.2 → imageio-2.35.1}/imageio/config/extensions.pyi +0 -0
  50. {imageio-2.34.2 → imageio-2.35.1}/imageio/config/plugins.pyi +0 -0
  51. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/__init__.py +0 -0
  52. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/fetching.py +0 -0
  53. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/findlib.py +0 -0
  54. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/format.py +0 -0
  55. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/format.pyi +0 -0
  56. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/imopen.py +0 -0
  57. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/legacy_plugin_wrapper.py +0 -0
  58. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/legacy_plugin_wrapper.pyi +0 -0
  59. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/request.py +0 -0
  60. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/request.pyi +0 -0
  61. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/util.py +0 -0
  62. {imageio-2.34.2 → imageio-2.35.1}/imageio/core/v3_plugin_api.py +0 -0
  63. {imageio-2.34.2 → imageio-2.35.1}/imageio/freeze.py +0 -0
  64. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/__init__.py +0 -0
  65. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/_bsdf.py +0 -0
  66. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/_dicom.py +0 -0
  67. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/_freeimage.py +0 -0
  68. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/_swf.py +0 -0
  69. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/_tifffile.py +0 -0
  70. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/bsdf.py +0 -0
  71. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/dicom.py +0 -0
  72. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/example.py +0 -0
  73. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/feisem.py +0 -0
  74. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/ffmpeg.py +0 -0
  75. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/fits.py +0 -0
  76. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/freeimage.py +0 -0
  77. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/freeimagemulti.py +0 -0
  78. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/gdal.py +0 -0
  79. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/grab.py +0 -0
  80. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/lytro.py +0 -0
  81. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/npz.py +0 -0
  82. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/opencv.py +0 -0
  83. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/pillow.py +0 -0
  84. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/pillow_info.py +0 -0
  85. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/pillow_legacy.py +0 -0
  86. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/pillowmulti.py +0 -0
  87. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/simpleitk.py +0 -0
  88. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/spe.py +0 -0
  89. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/swf.py +0 -0
  90. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/tifffile.py +0 -0
  91. {imageio-2.34.2 → imageio-2.35.1}/imageio/plugins/tifffile_v3.py +0 -0
  92. {imageio-2.34.2 → imageio-2.35.1}/imageio/py.typed +0 -0
  93. {imageio-2.34.2 → imageio-2.35.1}/imageio/testing.py +0 -0
  94. {imageio-2.34.2 → imageio-2.35.1}/imageio/typing.py +0 -0
  95. {imageio-2.34.2 → imageio-2.35.1}/imageio/v2.py +0 -0
  96. {imageio-2.34.2 → imageio-2.35.1}/imageio/v2.pyi +0 -0
  97. {imageio-2.34.2 → imageio-2.35.1}/imageio/v3.py +0 -0
  98. {imageio-2.34.2 → imageio-2.35.1}/imageio/v3.pyi +0 -0
  99. {imageio-2.34.2 → imageio-2.35.1}/imageio.egg-info/dependency_links.txt +0 -0
  100. {imageio-2.34.2 → imageio-2.35.1}/imageio.egg-info/entry_points.txt +0 -0
  101. {imageio-2.34.2 → imageio-2.35.1}/imageio.egg-info/not-zip-safe +0 -0
  102. {imageio-2.34.2 → imageio-2.35.1}/imageio.egg-info/top_level.txt +0 -0
  103. {imageio-2.34.2 → imageio-2.35.1}/setup.cfg +0 -0
  104. {imageio-2.34.2 → imageio-2.35.1}/tests/conftest.py +0 -0
  105. {imageio-2.34.2 → imageio-2.35.1}/tests/test_bsdf.py +0 -0
  106. {imageio-2.34.2 → imageio-2.35.1}/tests/test_config.py +0 -0
  107. {imageio-2.34.2 → imageio-2.35.1}/tests/test_core.py +0 -0
  108. {imageio-2.34.2 → imageio-2.35.1}/tests/test_dicom.py +0 -0
  109. {imageio-2.34.2 → imageio-2.35.1}/tests/test_fei_tiff.py +0 -0
  110. {imageio-2.34.2 → imageio-2.35.1}/tests/test_ffmpeg.py +0 -0
  111. {imageio-2.34.2 → imageio-2.35.1}/tests/test_ffmpeg_info.py +0 -0
  112. {imageio-2.34.2 → imageio-2.35.1}/tests/test_fits.py +0 -0
  113. {imageio-2.34.2 → imageio-2.35.1}/tests/test_format.py +0 -0
  114. {imageio-2.34.2 → imageio-2.35.1}/tests/test_freeimage.py +0 -0
  115. {imageio-2.34.2 → imageio-2.35.1}/tests/test_gdal.py +0 -0
  116. {imageio-2.34.2 → imageio-2.35.1}/tests/test_grab.py +0 -0
  117. {imageio-2.34.2 → imageio-2.35.1}/tests/test_legacy_plugin_wrapper.py +0 -0
  118. {imageio-2.34.2 → imageio-2.35.1}/tests/test_lytro.py +0 -0
  119. {imageio-2.34.2 → imageio-2.35.1}/tests/test_meta.py +0 -0
  120. {imageio-2.34.2 → imageio-2.35.1}/tests/test_npz.py +0 -0
  121. {imageio-2.34.2 → imageio-2.35.1}/tests/test_opencv.py +0 -0
  122. {imageio-2.34.2 → imageio-2.35.1}/tests/test_pillow_legacy.py +0 -0
  123. {imageio-2.34.2 → imageio-2.35.1}/tests/test_simpleitk.py +0 -0
  124. {imageio-2.34.2 → imageio-2.35.1}/tests/test_spe.py +0 -0
  125. {imageio-2.34.2 → imageio-2.35.1}/tests/test_swf.py +0 -0
  126. {imageio-2.34.2 → imageio-2.35.1}/tests/test_tifffile.py +0 -0
  127. {imageio-2.34.2 → imageio-2.35.1}/tests/test_tifffile_v3.py +0 -0
  128. {imageio-2.34.2 → imageio-2.35.1}/tests/test_v2.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imageio
3
- Version: 2.34.2
3
+ Version: 2.35.1
4
4
  Summary: Library for reading and writing a wide range of image, video, scientific, and volumetric data formats.
5
5
  Home-page: https://github.com/imageio/imageio
6
6
  Download-URL: http://pypi.python.org/pypi/imageio
@@ -41,10 +41,11 @@ Provides-Extra: spe
41
41
  Provides-Extra: swf
42
42
  Provides-Extra: tifffile
43
43
  Provides-Extra: pyav
44
- Provides-Extra: pillow-heif
45
44
  Provides-Extra: fits
46
45
  Provides-Extra: gdal
47
46
  Provides-Extra: itk
47
+ Provides-Extra: rawpy
48
+ Provides-Extra: pillow-heif
48
49
  Provides-Extra: full
49
50
  Provides-Extra: dev
50
51
  Provides-Extra: all-plugins
@@ -11,13 +11,13 @@
11
11
  # All configuration values have a default; values that are commented out
12
12
  # serve to show the default.
13
13
 
14
- import sys
15
- import os
16
- import imageio
17
- import inspect
18
14
  import importlib
15
+ import inspect
16
+ import os
17
+ import sys
19
18
  from pathlib import Path
20
19
 
20
+ import imageio
21
21
 
22
22
  # import/load the plugins so that they can be documented
23
23
  import imageio.plugins.bsdf
@@ -33,7 +33,6 @@ import imageio.plugins.simpleitk
33
33
  import imageio.plugins.spe
34
34
  import imageio.plugins.swf
35
35
 
36
-
37
36
  # If extensions (or modules to document with autodoc) are in another directory,
38
37
  # add these directories to sys.path here. If the directory is relative to the
39
38
  # documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -62,7 +61,7 @@ SphinxDocString._str_member_list = lambda self, name: []
62
61
 
63
62
  # Add any paths that contain templates here, relative to this directory.
64
63
  templates_path = ["_templates"]
65
- autodoc_mock_imports = ["av", "cv2", "imageio_ffmpeg", "tifffile"]
64
+ autodoc_mock_imports = ["av", "cv2", "imageio_ffmpeg", "rawpy", "tifffile"]
66
65
 
67
66
  # The suffix of source filenames.
68
67
  source_suffix = ".rst"
@@ -75,7 +74,7 @@ master_doc = "index"
75
74
 
76
75
  # General information about the project.
77
76
  project = "imageio"
78
- copyright = "2014-2021, imageio contributors"
77
+ copyright = "2014-2024, imageio contributors"
79
78
 
80
79
  # The version info for the project you're documenting, acts as replacement for
81
80
  # |version| and |release|, also used in various other places throughout the
@@ -95,6 +95,7 @@ support.
95
95
  imageio.plugins.pillow
96
96
  imageio.plugins.pillow_legacy
97
97
  imageio.plugins.pyav
98
+ imageio.plugins.rawpy
98
99
  imageio.plugins.simpleitk
99
100
  imageio.plugins.spe
100
101
  imageio.plugins.swf
@@ -16,7 +16,7 @@ Main website: https://imageio.readthedocs.io/
16
16
 
17
17
  # flake8: noqa
18
18
 
19
- __version__ = "2.34.2"
19
+ __version__ = "2.35.1"
20
20
 
21
21
  import warnings
22
22
 
@@ -596,7 +596,7 @@ extension_list = [
596
596
  ),
597
597
  FileExtension(
598
598
  extension=".nef",
599
- priority=["RAW-FI"],
599
+ priority=["RAW-FI", "rawpy"],
600
600
  ),
601
601
  FileExtension(
602
602
  extension=".nhdr",
@@ -762,7 +762,7 @@ extension_list = [
762
762
  ),
763
763
  FileExtension(
764
764
  extension=".raw",
765
- priority=["RAW-FI", "LYTRO-ILLUM-RAW", "LYTRO-F01-RAW"],
765
+ priority=["RAW-FI", "LYTRO-ILLUM-RAW", "LYTRO-F01-RAW", "rawpy"],
766
766
  ),
767
767
  FileExtension(
768
768
  extension=".rdc",
@@ -129,7 +129,9 @@ known_plugins["tifffile"] = PluginConfig(
129
129
  known_plugins["SPE"] = PluginConfig(
130
130
  name="spe", class_name="SpePlugin", module_name="imageio.plugins.spe"
131
131
  )
132
-
132
+ known_plugins["rawpy"] = PluginConfig(
133
+ name="rawpy", class_name="RawPyPlugin", module_name="imageio.plugins.rawpy"
134
+ )
133
135
 
134
136
  # Legacy plugins
135
137
  # ==============
@@ -3,6 +3,7 @@ from typing import Literal, Type, TypeVar, overload
3
3
  from ..plugins.opencv import OpenCVPlugin
4
4
  from ..plugins.pillow import PillowPlugin
5
5
  from ..plugins.pyav import PyAVPlugin
6
+ from ..plugins.rawpy import RawPyPlugin
6
7
  from ..plugins.tifffile_v3 import TifffilePlugin
7
8
  from ..typing import ImageResource
8
9
  from .legacy_plugin_wrapper import LegacyPlugin
@@ -48,6 +49,15 @@ def imopen(
48
49
  format_hint: str = None,
49
50
  ) -> PillowPlugin: ...
50
51
  @overload
52
+ def imopen(
53
+ uri: ImageResource,
54
+ io_mode: Literal["r", "w"],
55
+ *,
56
+ plugin: Literal["rawpy"],
57
+ extension: str = None,
58
+ format_hint: str = None,
59
+ ) -> RawPyPlugin: ...
60
+ @overload
51
61
  def imopen(
52
62
  uri: ImageResource,
53
63
  io_mode: Literal["r", "w"],
@@ -780,8 +780,15 @@ class PyAVPlugin(PluginV3):
780
780
  if is_write and self._video_stream is not None:
781
781
  self._flush_writer()
782
782
 
783
+ if self._video_stream is not None:
784
+ try:
785
+ self._video_stream.close()
786
+ except ValueError:
787
+ pass # stream already closed
788
+
783
789
  if self._container is not None:
784
790
  self._container.close()
791
+
785
792
  self.request.finish()
786
793
 
787
794
  def __enter__(self) -> "PyAVPlugin":
@@ -0,0 +1,191 @@
1
+ """ Read/Write images using rawpy.
2
+
3
+ rawpy is an easy-to-use Python wrapper for the LibRaw library.
4
+ It also contains some extra functionality for finding and repairing hot/dead pixels.
5
+ """
6
+
7
+ from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
8
+ import rawpy
9
+ import numpy as np
10
+
11
+ from ..core.request import URI_BYTES, InitializationError, IOMode, Request
12
+ from ..core.v3_plugin_api import ImageProperties, PluginV3
13
+ from ..typing import ArrayLike
14
+
15
+
16
+ class RawPyPlugin(PluginV3):
17
+ """A class representing the rawpy plugin.
18
+
19
+ Methods
20
+ -------
21
+
22
+ .. autosummary::
23
+ :toctree: _plugins/rawpy
24
+
25
+ RawPyPlugin.read
26
+ """
27
+
28
+ def __init__(self, request: Request) -> None:
29
+ """Instantiates a new rawpy plugin object
30
+
31
+ Parameters
32
+ ----------
33
+ request: Request
34
+ A request object representing the resource to be operated on.
35
+ """
36
+
37
+ super().__init__(request)
38
+
39
+ self._image_file = None
40
+
41
+ if request.mode.io_mode == IOMode.read:
42
+ try:
43
+ self._image_file = rawpy.imread(request.get_file())
44
+ except (
45
+ rawpy.NotSupportedError,
46
+ rawpy.LibRawFileUnsupportedError,
47
+ rawpy.LibRawIOError,
48
+ ):
49
+ if request._uri_type == URI_BYTES:
50
+ raise InitializationError(
51
+ "RawPy can not read the provided bytes."
52
+ ) from None
53
+ else:
54
+ raise InitializationError(
55
+ f"RawPy can not read {request.raw_uri}."
56
+ ) from None
57
+ elif request.mode.io_mode == IOMode.write:
58
+ raise InitializationError("RawPy does not support writing.") from None
59
+
60
+ def close(self) -> None:
61
+ if self._image_file:
62
+ self._image_file.close()
63
+
64
+ self._request.finish()
65
+
66
+ def read(self, *, index: int = 0, **kwargs) -> np.ndarray:
67
+ """Read Raw Image.
68
+
69
+ Returns
70
+ -------
71
+ nd_image: ndarray
72
+ The image data
73
+ """
74
+
75
+ nd_image: np.ndarray
76
+
77
+ try:
78
+ nd_image = self._image_file.postprocess(**kwargs)
79
+ except Exception:
80
+ pass
81
+
82
+ if index is Ellipsis:
83
+ nd_image = nd_image[None, ...]
84
+
85
+ return nd_image
86
+
87
+ def write(self, ndimage: Union[ArrayLike, List[ArrayLike]]) -> Optional[bytes]:
88
+ """RawPy does not support writing."""
89
+ raise NotImplementedError()
90
+
91
+ def iter(self) -> Iterator[np.ndarray]:
92
+ """Load the image.
93
+
94
+ Returns
95
+ -------
96
+ nd_image: ndarray
97
+ The image data
98
+ """
99
+
100
+ try:
101
+ yield self.read()
102
+ except Exception:
103
+ pass
104
+
105
+ def metadata(
106
+ self, index: int = None, exclude_applied: bool = True
107
+ ) -> Dict[str, Any]:
108
+ """Read ndimage metadata.
109
+
110
+ Parameters
111
+ ----------
112
+ exclude_applied : bool
113
+ If True, exclude metadata fields that are applied to the image while
114
+ reading. For example, if the binary data contains a rotation flag,
115
+ the image is rotated by default and the rotation flag is excluded
116
+ from the metadata to avoid confusion.
117
+
118
+ Returns
119
+ -------
120
+ metadata : dict
121
+ A dictionary of format-specific metadata.
122
+
123
+ """
124
+
125
+ metadata = {}
126
+
127
+ image_size = self._image_file.sizes
128
+
129
+ metadata["black_level_per_channel"] = self._image_file.black_level_per_channel
130
+ metadata["camera_white_level_per_channel"] = (
131
+ self._image_file.camera_white_level_per_channel
132
+ )
133
+ metadata["color_desc"] = self._image_file.color_desc
134
+ metadata["color_matrix"] = self._image_file.color_matrix
135
+ metadata["daylight_whitebalance"] = self._image_file.daylight_whitebalance
136
+ metadata["dtype"] = self._image_file.raw_image.dtype
137
+ metadata["flip"] = image_size.flip
138
+ metadata["num_colors"] = self._image_file.num_colors
139
+ metadata["tone_curve"] = self._image_file.tone_curve
140
+ metadata["width"] = image_size.width
141
+ metadata["height"] = image_size.height
142
+ metadata["raw_width"] = image_size.raw_width
143
+ metadata["raw_height"] = image_size.raw_height
144
+ metadata["raw_shape"] = self._image_file.raw_image.shape
145
+ metadata["iwidth"] = image_size.iwidth
146
+ metadata["iheight"] = image_size.iheight
147
+ metadata["pixel_aspect"] = image_size.pixel_aspect
148
+ metadata["white_level"] = self._image_file.white_level
149
+
150
+ if exclude_applied:
151
+ metadata.pop("black_level_per_channel", None)
152
+ metadata.pop("camera_white_level_per_channel", None)
153
+ metadata.pop("color_desc", None)
154
+ metadata.pop("color_matrix", None)
155
+ metadata.pop("daylight_whitebalance", None)
156
+ metadata.pop("dtype", None)
157
+ metadata.pop("flip", None)
158
+ metadata.pop("num_colors", None)
159
+ metadata.pop("tone_curve", None)
160
+ metadata.pop("raw_width", None)
161
+ metadata.pop("raw_height", None)
162
+ metadata.pop("raw_shape", None)
163
+ metadata.pop("iwidth", None)
164
+ metadata.pop("iheight", None)
165
+ metadata.pop("white_level", None)
166
+
167
+ return metadata
168
+
169
+ def properties(self, index: int = None) -> ImageProperties:
170
+ """Standardized ndimage metadata
171
+
172
+ Returns
173
+ -------
174
+ properties : ImageProperties
175
+ A dataclass filled with standardized image metadata.
176
+
177
+ Notes
178
+ -----
179
+ This does not decode pixel data and is fast for large images.
180
+
181
+ """
182
+
183
+ ImageSize = self._image_file.sizes
184
+
185
+ width: int = ImageSize.width
186
+ height: int = ImageSize.height
187
+ shape: Tuple[int, ...] = (height, width)
188
+
189
+ dtype = self._image_file.raw_image.dtype
190
+
191
+ return ImageProperties(shape=shape, dtype=dtype)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imageio
3
- Version: 2.34.2
3
+ Version: 2.35.1
4
4
  Summary: Library for reading and writing a wide range of image, video, scientific, and volumetric data formats.
5
5
  Home-page: https://github.com/imageio/imageio
6
6
  Download-URL: http://pypi.python.org/pypi/imageio
@@ -41,10 +41,11 @@ Provides-Extra: spe
41
41
  Provides-Extra: swf
42
42
  Provides-Extra: tifffile
43
43
  Provides-Extra: pyav
44
- Provides-Extra: pillow-heif
45
44
  Provides-Extra: fits
46
45
  Provides-Extra: gdal
47
46
  Provides-Extra: itk
47
+ Provides-Extra: rawpy
48
+ Provides-Extra: pillow-heif
48
49
  Provides-Extra: full
49
50
  Provides-Extra: dev
50
51
  Provides-Extra: all-plugins
@@ -91,6 +91,7 @@ imageio/plugins/pillow_info.py
91
91
  imageio/plugins/pillow_legacy.py
92
92
  imageio/plugins/pillowmulti.py
93
93
  imageio/plugins/pyav.py
94
+ imageio/plugins/rawpy.py
94
95
  imageio/plugins/simpleitk.py
95
96
  imageio/plugins/spe.py
96
97
  imageio/plugins/swf.py
@@ -117,6 +118,7 @@ tests/test_opencv.py
117
118
  tests/test_pillow.py
118
119
  tests/test_pillow_legacy.py
119
120
  tests/test_pyav.py
121
+ tests/test_rawpy.py
120
122
  tests/test_simpleitk.py
121
123
  tests/test_spe.py
122
124
  tests/test_swf.py
@@ -5,14 +5,12 @@ pillow>=8.3.2
5
5
  astropy
6
6
  av
7
7
  imageio-ffmpeg
8
- pillow-heif
9
8
  psutil
10
9
  tifffile
11
10
 
12
11
  [all-plugins-pypy]
13
12
  av
14
13
  imageio-ffmpeg
15
- pillow-heif
16
14
  psutil
17
15
  tifffile
18
16
 
@@ -55,12 +53,14 @@ fsspec[github]
55
53
  gdal
56
54
  imageio-ffmpeg
57
55
  itk
56
+ numpy>2
58
57
  numpydoc
59
58
  pillow-heif
60
59
  psutil
61
60
  pydata-sphinx-theme
62
61
  pytest
63
62
  pytest-cov
63
+ rawpy
64
64
  sphinx<6
65
65
  tifffile
66
66
  wheel
@@ -87,6 +87,10 @@ pillow-heif
87
87
  [pyav]
88
88
  av
89
89
 
90
+ [rawpy]
91
+ rawpy
92
+ numpy>2
93
+
90
94
  [simpleitk]
91
95
 
92
96
  [spe]
@@ -99,7 +99,6 @@ plugins = {
99
99
  "swf": [],
100
100
  "tifffile": ["tifffile"],
101
101
  "pyav": ["av"],
102
- "pillow-heif": ["pillow-heif"],
103
102
  }
104
103
 
105
104
  cpython_only_plugins = {
@@ -115,6 +114,12 @@ extras_require = {
115
114
  **cpython_only_plugins,
116
115
  "gdal": ["gdal"], # gdal currently fails to install :(
117
116
  "itk": ["itk"], # itk builds from source (expensive on CI).
117
+ # TODO: move this to cpython_only_plugins when python 3.8 support is dropped
118
+ "rawpy": [
119
+ "rawpy",
120
+ "numpy>2",
121
+ ], # rawpy doesn't support python 3.8 (due to numpy > 2 requirement)
122
+ "pillow-heif": ["pillow-heif"], # pillow-heif doesn#t support py3.8 on MacOS ARM
118
123
  }
119
124
 
120
125
  extras_require["full"] = sorted(set(chain.from_iterable(extras_require.values())))
@@ -709,6 +709,7 @@ def test_writable_output():
709
709
 
710
710
  @pytest.mark.needs_internet
711
711
  def test_heif_remote():
712
+ pytest.importorskip("pillow_heif")
712
713
  url = "http://github.com/tigranbs/test-heic-images/raw/master/image4.heic"
713
714
  im = iio.imread(url, plugin="pillow")
714
715
  assert im.shape == (476, 700, 4)
@@ -716,6 +717,8 @@ def test_heif_remote():
716
717
 
717
718
  @pytest.mark.needs_internet
718
719
  def test_avif_remote():
720
+ pytest.importorskip("pillow_heif")
721
+
719
722
  url = "https://github.com/link-u/avif-sample-images/raw/master/fox.profile0.10bpc.yuv420.avif"
720
723
  im = iio.imread(url, plugin="pillow")
721
724
  assert im.shape == (800, 1204, 3)
@@ -1,4 +1,6 @@
1
+ import gc
1
2
  import io
3
+ import multiprocessing
2
4
  import warnings
3
5
  from contextlib import ExitStack
4
6
  from pathlib import Path
@@ -585,3 +587,32 @@ def test_trim_filter(test_images):
585
587
  )
586
588
 
587
589
  assert frames.shape == (20, 720, 1280, 3)
590
+
591
+
592
+ def subprocess(func, conn):
593
+ try:
594
+ result = func()
595
+ conn.send(result)
596
+ except BaseException as e:
597
+ conn.send(e)
598
+
599
+
600
+ def test_lagging_video_stream(test_images):
601
+ # this is a regression test
602
+ # see: https://github.com/imageio/imageio/issues/1095
603
+
604
+ with iio.imopen(
605
+ test_images / "cockatoo.mp4",
606
+ "r",
607
+ plugin="pyav",
608
+ ) as img_file:
609
+ for idx in range(50):
610
+ img_file.read(index=idx)
611
+
612
+ output, input = multiprocessing.Pipe()
613
+ proc = multiprocessing.Process(target=subprocess, args=(gc.collect, input))
614
+
615
+ proc.start()
616
+ if not output.poll(timeout=5):
617
+ proc.kill()
618
+ raise TimeoutError("Test Subprocess failed to respond in time.")
@@ -0,0 +1,81 @@
1
+ """Tests for rawpy plugin
2
+ """
3
+
4
+ import imageio.v3 as iio
5
+
6
+ import pytest
7
+ import numpy as np
8
+
9
+ rawpy = pytest.importorskip("rawpy")
10
+
11
+
12
+ @pytest.mark.parametrize(
13
+ "im_in",
14
+ [
15
+ ("Nikon_uncompressed.nef"),
16
+ ("Blackmagic.dng"),
17
+ ("Canon_Powershot.CRW"),
18
+ ("Pentax_compressed.PEF"),
19
+ ],
20
+ )
21
+ def test_read(test_images, im_in):
22
+ """Test for reading .nef file from .test_images dir."""
23
+ # Construct image path
24
+ im_path = test_images / im_in
25
+
26
+ # Test if plugin's content mathces rawpy content
27
+ actual = iio.imread(im_path, index=..., plugin="rawpy")
28
+ expected = rawpy.imread(str(im_path)).postprocess()
29
+ assert np.allclose(actual, expected)
30
+
31
+
32
+ @pytest.mark.parametrize(
33
+ "im_in",
34
+ [
35
+ ("Nikon_uncompressed.nef"),
36
+ ("Blackmagic.dng"),
37
+ ("Canon_Powershot.CRW"),
38
+ ("Pentax_compressed.PEF"),
39
+ ],
40
+ )
41
+ def test_read_with_default_index(test_images, im_in):
42
+ """Test for reading .nef file from .test_images dir."""
43
+ # Construct image path
44
+ im_path = test_images / im_in
45
+
46
+ # Test if plugin's content mathces rawpy content
47
+ actual = iio.imread(im_path, plugin="rawpy")
48
+ expected = rawpy.imread(str(im_path)).postprocess()
49
+ assert np.allclose(actual, expected)
50
+
51
+
52
+ def test_iter(test_images):
53
+ """Test for the iter function of rawpy plugin."""
54
+
55
+ # Construct image path
56
+ im_path = test_images / "Blackmagic.dng"
57
+
58
+ assert iio.imiter(im_path, plugin="rawpy")
59
+
60
+
61
+ def test_properties(test_images):
62
+ """Test for reading properties of a raw image from .test_images dir."""
63
+ # Construct image path
64
+ im_path = test_images / "Nikon_uncompressed.nef"
65
+
66
+ # Test properties of a .nef image
67
+ properties = iio.improps(im_path, plugin="rawpy")
68
+ assert properties.shape == (593, 869)
69
+ assert properties.dtype == np.uint16
70
+
71
+
72
+ def test_metadata(test_images):
73
+ """Test for reading metadata of a raw image from .test_images dir."""
74
+ # Construct image path
75
+ im_path = test_images / "Nikon_uncompressed.nef"
76
+
77
+ # Test metadata of a .nef image
78
+ metadata = iio.immeta(im_path, plugin="rawpy")
79
+ assert metadata["width"] == 869
80
+ assert metadata["height"] == 593
81
+ assert metadata["pixel_aspect"] == 1.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes