Skip to content

Commit 1ad08f5

Browse files
authored
Migrate remaining PIL features away (#628)
1 parent 5ae1b82 commit 1ad08f5

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "viam-sdk"
3-
version = "0.21.0"
3+
version = "0.21.1"
44
description = "Viam Robotics Python SDK"
55
authors = [ "Naveed <[email protected]>" ]
66
license = "Apache-2.0"

src/viam/media/utils/pil.py renamed to src/viam/media/utils/pil/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
from PIL import Image
44

5-
from viam.media.video import CameraMimeType, ViamImage
6-
7-
from ..viam_rgba_plugin import RGBA_FORMAT_LABEL
5+
from ....media.video import CameraMimeType, ViamImage
6+
from .viam_rgba_plugin import RGBA_FORMAT_LABEL
87

98
# Formats that are supported by PIL
109
LIBRARY_SUPPORTED_FORMATS = ["JPEG", "PNG", RGBA_FORMAT_LABEL]

src/viam/media/viam_rgba_plugin.py renamed to src/viam/media/utils/pil/viam_rgba_plugin.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,7 @@
44
from PIL.ImageFile import ImageFile, PyDecoder, PyEncoder, _safe_read # type: ignore -- (njooma) this exists, manually checked
55
from PIL.ImageFile import _save as image_save # type: ignore -- (njooma) this exists, manually checked
66

7-
# Viam uses a special header prepended to raw RGBA data. The header is composed of a
8-
# 4-byte magic number followed by a 4-byte line of the width as a uint32 number
9-
# and another for the height. Credit to Ben Zotto for inventing this formulation
10-
# https://bzotto.medium.com/introducing-the-rgba-bitmap-file-format-4a8a94329e2c
11-
12-
RGBA_MAGIC_NUMBER = bytes("RGBA", "utf-8")
13-
14-
RGBA_FORMAT_LABEL = "VIAM_RGBA"
15-
16-
RGBA_HEADER_LENGTH = 12
7+
from ...viam_rgba import RGBA_FORMAT_LABEL, RGBA_HEADER_LENGTH, RGBA_MAGIC_NUMBER
178

189

1910
def _accept(prefix: str):

src/viam/media/viam_rgba.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Viam uses a special header prepended to raw RGBA data. The header is composed of a
2+
# 4-byte magic number followed by a 4-byte line of the width as a uint32 number
3+
# and another for the height. Credit to Ben Zotto for inventing this formulation
4+
# https://bzotto.medium.com/introducing-the-rgba-bitmap-file-format-4a8a94329e2c
5+
6+
RGBA_MAGIC_NUMBER = bytes("RGBA", "utf-8")
7+
8+
RGBA_FORMAT_LABEL = "VIAM_RGBA"
9+
10+
RGBA_HEADER_LENGTH = 12

src/viam/media/video.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
from viam.errors import NotSupportedError
88
from viam.proto.component.camera import Format
99

10-
from .viam_rgba_plugin import RGBA_FORMAT_LABEL, RGBA_HEADER_LENGTH, RGBA_MAGIC_NUMBER
11-
12-
# Formats that are supported by PIL
13-
LIBRARY_SUPPORTED_FORMATS = ["JPEG", "PNG", RGBA_FORMAT_LABEL]
10+
from .viam_rgba import RGBA_HEADER_LENGTH, RGBA_MAGIC_NUMBER
1411

1512

1613
class CameraMimeType(str, Enum):

0 commit comments

Comments
 (0)