aboutsummaryrefslogtreecommitdiffstats
path: root/bsie/reader/image/_pillow.py
diff options
context:
space:
mode:
Diffstat (limited to 'bsie/reader/image/_pillow.py')
-rw-r--r--bsie/reader/image/_pillow.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/bsie/reader/image/_pillow.py b/bsie/reader/image/_pillow.py
new file mode 100644
index 0000000..ee0662d
--- /dev/null
+++ b/bsie/reader/image/_pillow.py
@@ -0,0 +1,37 @@
+"""
+
+Part of the bsie module.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# standard imports
+import typing
+
+# external imports
+import PIL.Image
+
+# bsie imports
+from bsie.utils import errors
+
+# inner-module imports
+from .. import base
+
+# exports
+__all__: typing.Sequence[str] = (
+ 'PillowImage',
+ )
+
+
+## code ##
+
+class PillowImage(base.Reader):
+ """Use PIL to read content of a variety of image file types."""
+
+ def __call__(self, path: str) -> PIL.Image:
+ try:
+ # open file with PIL
+ return PIL.Image.open(path)
+ except IOError as err:
+ raise errors.ReaderError(path) from err
+
+# EOF ##