diff --git a/pyproject.toml b/pyproject.toml index 62bd5b9aa..e2244a6cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "viam-sdk" -version = "0.21.0" +version = "0.21.1" description = "Viam Robotics Python SDK" authors = [ "Naveed " ] license = "Apache-2.0" diff --git a/src/viam/media/utils/pil.py b/src/viam/media/utils/pil/__init__.py similarity index 91% rename from src/viam/media/utils/pil.py rename to src/viam/media/utils/pil/__init__.py index 6f5103df3..ccc047475 100644 --- a/src/viam/media/utils/pil.py +++ b/src/viam/media/utils/pil/__init__.py @@ -2,9 +2,8 @@ from PIL import Image -from viam.media.video import CameraMimeType, ViamImage - -from ..viam_rgba_plugin import RGBA_FORMAT_LABEL +from ....media.video import CameraMimeType, ViamImage +from .viam_rgba_plugin import RGBA_FORMAT_LABEL # Formats that are supported by PIL LIBRARY_SUPPORTED_FORMATS = ["JPEG", "PNG", RGBA_FORMAT_LABEL] diff --git a/src/viam/media/viam_rgba_plugin.py b/src/viam/media/utils/pil/viam_rgba_plugin.py similarity index 85% rename from src/viam/media/viam_rgba_plugin.py rename to src/viam/media/utils/pil/viam_rgba_plugin.py index 620701328..75d1711d0 100644 --- a/src/viam/media/viam_rgba_plugin.py +++ b/src/viam/media/utils/pil/viam_rgba_plugin.py @@ -4,16 +4,7 @@ from PIL.ImageFile import ImageFile, PyDecoder, PyEncoder, _safe_read # type: ignore -- (njooma) this exists, manually checked from PIL.ImageFile import _save as image_save # type: ignore -- (njooma) this exists, manually checked -# Viam uses a special header prepended to raw RGBA data. The header is composed of a -# 4-byte magic number followed by a 4-byte line of the width as a uint32 number -# and another for the height. Credit to Ben Zotto for inventing this formulation -# https://bzotto.medium.com/introducing-the-rgba-bitmap-file-format-4a8a94329e2c - -RGBA_MAGIC_NUMBER = bytes("RGBA", "utf-8") - -RGBA_FORMAT_LABEL = "VIAM_RGBA" - -RGBA_HEADER_LENGTH = 12 +from ...viam_rgba import RGBA_FORMAT_LABEL, RGBA_HEADER_LENGTH, RGBA_MAGIC_NUMBER def _accept(prefix: str): diff --git a/src/viam/media/viam_rgba.py b/src/viam/media/viam_rgba.py new file mode 100644 index 000000000..c11ebe483 --- /dev/null +++ b/src/viam/media/viam_rgba.py @@ -0,0 +1,10 @@ +# Viam uses a special header prepended to raw RGBA data. The header is composed of a +# 4-byte magic number followed by a 4-byte line of the width as a uint32 number +# and another for the height. Credit to Ben Zotto for inventing this formulation +# https://bzotto.medium.com/introducing-the-rgba-bitmap-file-format-4a8a94329e2c + +RGBA_MAGIC_NUMBER = bytes("RGBA", "utf-8") + +RGBA_FORMAT_LABEL = "VIAM_RGBA" + +RGBA_HEADER_LENGTH = 12 diff --git a/src/viam/media/video.py b/src/viam/media/video.py index 0d3a4dd7f..56b3e86a8 100644 --- a/src/viam/media/video.py +++ b/src/viam/media/video.py @@ -7,10 +7,7 @@ from viam.errors import NotSupportedError from viam.proto.component.camera import Format -from .viam_rgba_plugin import RGBA_FORMAT_LABEL, RGBA_HEADER_LENGTH, RGBA_MAGIC_NUMBER - -# Formats that are supported by PIL -LIBRARY_SUPPORTED_FORMATS = ["JPEG", "PNG", RGBA_FORMAT_LABEL] +from .viam_rgba import RGBA_HEADER_LENGTH, RGBA_MAGIC_NUMBER class CameraMimeType(str, Enum):