haybale-image 0.3.2__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.
- haybale_image-0.3.2/.gitignore +227 -0
- haybale_image-0.3.2/PKG-INFO +13 -0
- haybale_image-0.3.2/README.md +34 -0
- haybale_image-0.3.2/haybale_image/OVERVIEW.md +30 -0
- haybale_image-0.3.2/haybale_image/QUICKREF.md +27 -0
- haybale_image-0.3.2/haybale_image/__init__.py +43 -0
- haybale_image-0.3.2/haybale_image/adapters/__init__.py +0 -0
- haybale_image-0.3.2/haybale_image/adapters/image_adapters.py +51 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.adapter.ImageToGrayAdapter.md +15 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.adapter.ImageToRgbAdapter.md +15 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.adapter.ImageToRgbaAdapter.md +15 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.node.ImageInfoNode.md +23 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.node.LoadImageNode.md +37 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.node.SaveImageNode.md +63 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.node.ViewImageNode.md +40 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.panel.ImageSettingsPanel.md +14 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.setting.ImageSettings.md +9 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.type.IMAGE.md +15 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.type.IMAGE_GRAY.md +15 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.type.IMAGE_RGB.md +15 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.type.IMAGE_RGBA.md +15 -0
- haybale_image-0.3.2/haybale_image/docs/haybale-image.widget.ImageViewerWidget.md +37 -0
- haybale_image-0.3.2/haybale_image/haybale.toml +13 -0
- haybale_image-0.3.2/haybale_image/helpers.py +110 -0
- haybale_image-0.3.2/haybale_image/io/__init__.py +23 -0
- haybale_image-0.3.2/haybale_image/io/_avif.py +49 -0
- haybale_image-0.3.2/haybale_image/io/codecs.py +245 -0
- haybale_image-0.3.2/haybale_image/io/formats.py +74 -0
- haybale_image-0.3.2/haybale_image/io/placement.py +92 -0
- haybale_image-0.3.2/haybale_image/nodes/__init__.py +0 -0
- haybale_image-0.3.2/haybale_image/nodes/image_info.py +44 -0
- haybale_image-0.3.2/haybale_image/nodes/load_image.py +58 -0
- haybale_image-0.3.2/haybale_image/nodes/save_image.py +228 -0
- haybale_image-0.3.2/haybale_image/nodes/view_image.py +101 -0
- haybale_image-0.3.2/haybale_image/panels/__init__.py +1 -0
- haybale_image-0.3.2/haybale_image/panels/image_settings_panel.py +31 -0
- haybale_image-0.3.2/haybale_image/py.typed +0 -0
- haybale_image-0.3.2/haybale_image/settings/__init__.py +0 -0
- haybale_image-0.3.2/haybale_image/settings/image_settings.py +51 -0
- haybale_image-0.3.2/haybale_image/types/__init__.py +0 -0
- haybale_image-0.3.2/haybale_image/types/image.py +109 -0
- haybale_image-0.3.2/haybale_image/value/__init__.py +8 -0
- haybale_image-0.3.2/haybale_image/value/_numpy_ops.py +81 -0
- haybale_image-0.3.2/haybale_image/value/_torch_ops.py +190 -0
- haybale_image-0.3.2/haybale_image/value/enums.py +18 -0
- haybale_image-0.3.2/haybale_image/value/image_value.py +304 -0
- haybale_image-0.3.2/haybale_image/value/layout.py +41 -0
- haybale_image-0.3.2/haybale_image/value/metadata.py +21 -0
- haybale_image-0.3.2/haybale_image/viewer/__init__.py +5 -0
- haybale_image-0.3.2/haybale_image/viewer/backend.py +299 -0
- haybale_image-0.3.2/haybale_image/viewer/image_viewer.js +337 -0
- haybale_image-0.3.2/haybale_image/widgets/__init__.py +0 -0
- haybale_image-0.3.2/haybale_image/widgets/image_viewer_widget.py +86 -0
- haybale_image-0.3.2/pyproject.toml +29 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# The MANIFEST/*.manifest packaging-artifact rules above are unanchored and
|
|
36
|
+
# (on a case-insensitive filesystem) also match our real, tracked
|
|
37
|
+
# haywire_studio/share/manifest/ package — un-ignore it explicitly.
|
|
38
|
+
!packages/haywire-studio/src/haywire_studio/share/manifest/
|
|
39
|
+
|
|
40
|
+
# Installer logs
|
|
41
|
+
pip-log.txt
|
|
42
|
+
pip-delete-this-directory.txt
|
|
43
|
+
|
|
44
|
+
# Unit test / coverage reports
|
|
45
|
+
htmlcov/
|
|
46
|
+
.tox/
|
|
47
|
+
.nox/
|
|
48
|
+
.coverage
|
|
49
|
+
.coverage.*
|
|
50
|
+
.cache
|
|
51
|
+
nosetests.xml
|
|
52
|
+
coverage.xml
|
|
53
|
+
*.cover
|
|
54
|
+
*.py,cover
|
|
55
|
+
.hypothesis/
|
|
56
|
+
.pytest_cache/
|
|
57
|
+
cover/
|
|
58
|
+
|
|
59
|
+
# Translations
|
|
60
|
+
*.mo
|
|
61
|
+
*.pot
|
|
62
|
+
|
|
63
|
+
# Django stuff:
|
|
64
|
+
*.log
|
|
65
|
+
local_settings.py
|
|
66
|
+
db.sqlite3
|
|
67
|
+
db.sqlite3-journal
|
|
68
|
+
|
|
69
|
+
# Flask stuff:
|
|
70
|
+
instance/
|
|
71
|
+
.webassets-cache
|
|
72
|
+
|
|
73
|
+
# Scrapy stuff:
|
|
74
|
+
.scrapy
|
|
75
|
+
|
|
76
|
+
# Sphinx documentation
|
|
77
|
+
docs/_build/
|
|
78
|
+
|
|
79
|
+
# PyBuilder
|
|
80
|
+
.pybuilder/
|
|
81
|
+
target/
|
|
82
|
+
|
|
83
|
+
# Jupyter Notebook
|
|
84
|
+
.ipynb_checkpoints
|
|
85
|
+
|
|
86
|
+
# IPython
|
|
87
|
+
profile_default/
|
|
88
|
+
ipython_config.py
|
|
89
|
+
|
|
90
|
+
# pyenv
|
|
91
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
92
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
93
|
+
# .python-version
|
|
94
|
+
|
|
95
|
+
# pipenv
|
|
96
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
97
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
98
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
99
|
+
# install all needed dependencies.
|
|
100
|
+
#Pipfile.lock
|
|
101
|
+
|
|
102
|
+
# UV
|
|
103
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
104
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
105
|
+
# commonly ignored for libraries.
|
|
106
|
+
#uv.lock
|
|
107
|
+
|
|
108
|
+
# poetry
|
|
109
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
110
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
111
|
+
# commonly ignored for libraries.
|
|
112
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
113
|
+
#poetry.lock
|
|
114
|
+
|
|
115
|
+
# pdm
|
|
116
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
117
|
+
#pdm.lock
|
|
118
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
119
|
+
# in version control.
|
|
120
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
121
|
+
.pdm.toml
|
|
122
|
+
.pdm-python
|
|
123
|
+
.pdm-build/
|
|
124
|
+
|
|
125
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
126
|
+
__pypackages__/
|
|
127
|
+
|
|
128
|
+
# Celery stuff
|
|
129
|
+
celerybeat-schedule
|
|
130
|
+
celerybeat.pid
|
|
131
|
+
|
|
132
|
+
# SageMath parsed files
|
|
133
|
+
*.sage.py
|
|
134
|
+
|
|
135
|
+
# Environments
|
|
136
|
+
**/.env
|
|
137
|
+
.venv
|
|
138
|
+
env/
|
|
139
|
+
venv/
|
|
140
|
+
ENV/
|
|
141
|
+
env.bak/
|
|
142
|
+
venv.bak/
|
|
143
|
+
|
|
144
|
+
# Spyder project settings
|
|
145
|
+
.spyderproject
|
|
146
|
+
.spyproject
|
|
147
|
+
|
|
148
|
+
# Rope project settings
|
|
149
|
+
.ropeproject
|
|
150
|
+
|
|
151
|
+
# mkdocs documentation
|
|
152
|
+
/site
|
|
153
|
+
|
|
154
|
+
# mypy
|
|
155
|
+
.mypy_cache/
|
|
156
|
+
.dmypy.json
|
|
157
|
+
dmypy.json
|
|
158
|
+
|
|
159
|
+
# Pyre type checker
|
|
160
|
+
.pyre/
|
|
161
|
+
|
|
162
|
+
# pytype static type analyzer
|
|
163
|
+
.pytype/
|
|
164
|
+
|
|
165
|
+
# Cython debug symbols
|
|
166
|
+
cython_debug/
|
|
167
|
+
|
|
168
|
+
# PyCharm
|
|
169
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
170
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
171
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
172
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
173
|
+
.idea/
|
|
174
|
+
|
|
175
|
+
# Abstra
|
|
176
|
+
# Abstra is an AI-powered process automation framework.
|
|
177
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
178
|
+
# Learn more at https://abstra.io/docs
|
|
179
|
+
.abstra/
|
|
180
|
+
|
|
181
|
+
# Visual Studio Code
|
|
182
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
183
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
184
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
185
|
+
# you could uncomment the following to ignore the enitre vscode folder
|
|
186
|
+
.vscode/
|
|
187
|
+
|
|
188
|
+
# Ruff stuff:
|
|
189
|
+
.ruff_cache/
|
|
190
|
+
|
|
191
|
+
# PyPI configuration file
|
|
192
|
+
.pypirc
|
|
193
|
+
|
|
194
|
+
# Cursor
|
|
195
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
196
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
197
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
198
|
+
.cursorignore
|
|
199
|
+
.cursorindexingignore
|
|
200
|
+
|
|
201
|
+
.DS_Store
|
|
202
|
+
saves/*.*
|
|
203
|
+
|
|
204
|
+
# Dev-mode graphs (local testing only, not part of the repo)
|
|
205
|
+
graphs/*.json
|
|
206
|
+
# MkDocs build output
|
|
207
|
+
site/
|
|
208
|
+
|
|
209
|
+
# Baked docs for the haywire-core wheel (generated by scripts/bake_docs.py;
|
|
210
|
+
# force-included into the wheel at build time). The *contents* are never
|
|
211
|
+
# committed, but the directory itself is kept via a committed .gitkeep so the
|
|
212
|
+
# hatchling force-include target exists in a fresh checkout — otherwise every
|
|
213
|
+
# editable install (`uv sync`) fails the build on a missing force-include path.
|
|
214
|
+
packages/haywire-core/src/haywire/_baked_docs/*
|
|
215
|
+
!packages/haywire-core/src/haywire/_baked_docs/.gitkeep
|
|
216
|
+
|
|
217
|
+
# Local git worktrees (claude-code workflow)
|
|
218
|
+
.worktrees/
|
|
219
|
+
|
|
220
|
+
# Haywire project config (user-local, not repo state)
|
|
221
|
+
.haywire/
|
|
222
|
+
|
|
223
|
+
# Local symlinks to external dev projects (machine-specific paths)
|
|
224
|
+
barn/haybale-visiongraph
|
|
225
|
+
barn/haybale-spandrel
|
|
226
|
+
|
|
227
|
+
assets/*
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: haybale-image
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: Image types, IO and viewers shared by vision and ML libraries
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: image
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Requires-Dist: haywire-core>=0.3.2
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: opencv-contrib-python>=5.0.0.93
|
|
11
|
+
Requires-Dist: pillow>=12.0
|
|
12
|
+
Provides-Extra: torch
|
|
13
|
+
Requires-Dist: torch; extra == 'torch'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Image
|
|
2
|
+
|
|
3
|
+
<!-- marketstall:share-url:start -->
|
|
4
|
+
*Subscribe URL not yet published — run `haywire share --save`.*
|
|
5
|
+
<!-- marketstall:share-url:end -->
|
|
6
|
+
|
|
7
|
+
Image types, IO and viewers shared by vision and ML libraries
|
|
8
|
+
|
|
9
|
+
## Nodes
|
|
10
|
+
### Image
|
|
11
|
+
- **Image Info** — Reports the width, height, channel layout and bit depth of an image
|
|
12
|
+
- **Load Image** — Reads an image file from a volume
|
|
13
|
+
- **Save Image** — Writes an image to a file in a volume, in the format its extension names
|
|
14
|
+
- **View Image** — Shows an image on the node, as a live stream or as a still picture
|
|
15
|
+
|
|
16
|
+
## Types
|
|
17
|
+
- **Gray image** — A one-channel picture.
|
|
18
|
+
- **Image** — A picture of any channel layout. Pixels are kept as made and converted on demand.
|
|
19
|
+
- **RGB image** — A three-channel picture.
|
|
20
|
+
- **RGBA image** — A picture with three colour channels and transparency.
|
|
21
|
+
|
|
22
|
+
## Adapters
|
|
23
|
+
- **ImageToGrayAdapter** — Convert an image to gray
|
|
24
|
+
- **ImageToRgbAdapter** — Convert an image to RGB
|
|
25
|
+
- **ImageToRgbaAdapter** — Convert an image to RGBA
|
|
26
|
+
|
|
27
|
+
## Widgets
|
|
28
|
+
- **ImageViewerWidget** — Shows an image, as a live stream or as a still picture
|
|
29
|
+
|
|
30
|
+
## Settings
|
|
31
|
+
- **Image** — Defaults for saving images
|
|
32
|
+
|
|
33
|
+
## Panels
|
|
34
|
+
- **Image** — Defaults for saving images.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Image
|
|
2
|
+
|
|
3
|
+
Image types, IO and viewers shared by vision and ML libraries
|
|
4
|
+
|
|
5
|
+
## Nodes
|
|
6
|
+
### Image
|
|
7
|
+
- **Image Info** — Reports the width, height, channel layout and bit depth of an image
|
|
8
|
+
- **Load Image** — Reads an image file from a volume
|
|
9
|
+
- **Save Image** — Writes an image to a file in a volume, in the format its extension names
|
|
10
|
+
- **View Image** — Shows an image on the node, as a live stream or as a still picture
|
|
11
|
+
|
|
12
|
+
## Types
|
|
13
|
+
- **Gray image** — A one-channel picture.
|
|
14
|
+
- **Image** — A picture of any channel layout. Pixels are kept as made and converted on demand.
|
|
15
|
+
- **RGB image** — A three-channel picture.
|
|
16
|
+
- **RGBA image** — A picture with three colour channels and transparency.
|
|
17
|
+
|
|
18
|
+
## Adapters
|
|
19
|
+
- **ImageToGrayAdapter** — Convert an image to gray
|
|
20
|
+
- **ImageToRgbAdapter** — Convert an image to RGB
|
|
21
|
+
- **ImageToRgbaAdapter** — Convert an image to RGBA
|
|
22
|
+
|
|
23
|
+
## Widgets
|
|
24
|
+
- **ImageViewerWidget** — Shows an image, as a live stream or as a still picture
|
|
25
|
+
|
|
26
|
+
## Settings
|
|
27
|
+
- **Image** — Defaults for saving images
|
|
28
|
+
|
|
29
|
+
## Panels
|
|
30
|
+
- **Image** — Defaults for saving images.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# haybale-image — component index (v0.3.2)
|
|
2
|
+
|
|
3
|
+
## node
|
|
4
|
+
- `haybale-image:node:ImageInfoNode` — Image Info — Reports the width, height, channel layout and bit depth of an image _tags: image, info, size, width, height, layout, depth, channels_
|
|
5
|
+
- `haybale-image:node:LoadImageNode` — Load Image — Reads an image file from a volume _tags: image, load, open, read, file, png, jpg, tiff, import_
|
|
6
|
+
- `haybale-image:node:SaveImageNode` — Save Image — Writes an image to a file in a volume, in the format its extension names _tags: image, save, write, export, file, png, jpg, tiff, webp_
|
|
7
|
+
- `haybale-image:node:ViewImageNode` — View Image — Shows an image on the node, as a live stream or as a still picture _tags: image, view, show, preview, display, viewer, stream_
|
|
8
|
+
|
|
9
|
+
## type
|
|
10
|
+
- `haybale-image:type:IMAGE` — Image — A picture of any channel layout. Pixels are kept as made and converted on demand.
|
|
11
|
+
- `haybale-image:type:IMAGE_GRAY` — Gray image — A one-channel picture.
|
|
12
|
+
- `haybale-image:type:IMAGE_RGB` — RGB image — A three-channel picture.
|
|
13
|
+
- `haybale-image:type:IMAGE_RGBA` — RGBA image — A picture with three colour channels and transparency.
|
|
14
|
+
|
|
15
|
+
## adapter
|
|
16
|
+
- `haybale-image:adapter:ImageToGrayAdapter` — ImageToGrayAdapter — Convert an image to gray
|
|
17
|
+
- `haybale-image:adapter:ImageToRgbAdapter` — ImageToRgbAdapter — Convert an image to RGB
|
|
18
|
+
- `haybale-image:adapter:ImageToRgbaAdapter` — ImageToRgbaAdapter — Convert an image to RGBA
|
|
19
|
+
|
|
20
|
+
## widget
|
|
21
|
+
- `haybale-image:widget:ImageViewerWidget` — ImageViewerWidget — Shows an image, as a live stream or as a still picture
|
|
22
|
+
|
|
23
|
+
## setting
|
|
24
|
+
- `haybale-image:setting:ImageSettings` — Image — Defaults for saving images
|
|
25
|
+
|
|
26
|
+
## panel
|
|
27
|
+
- `haybale-image:panel:ImageSettingsPanel` — Image — Defaults for saving images.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Haybale-Image: image values shared by vision and ML libraries.
|
|
2
|
+
|
|
3
|
+
Provides:
|
|
4
|
+
- ImageValue (``haybale_image.value``): an image with fixed semantics (RGB order,
|
|
5
|
+
values in [0, 1], layout, source depth) and free storage (dtype, channel order,
|
|
6
|
+
numpy array or torch tensor on any device), reached only through accessors.
|
|
7
|
+
|
|
8
|
+
Component folders (registered in ``register_components``):
|
|
9
|
+
- ``settings``, ``types``, ``adapters``, ``widgets``, ``nodes``, ``panels``: the IMAGE types,
|
|
10
|
+
adapters, widgets, IO nodes and the library settings panel.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
from haywire.core.library.base import BaseLibrary
|
|
16
|
+
from haywire.core.library.decorator import library
|
|
17
|
+
from haywire.core.settings.registry import SettingsRegistry
|
|
18
|
+
from haywire.core.adapter.registry import AdapterRegistry
|
|
19
|
+
from haywire.core.node.registry import NodeRegistry
|
|
20
|
+
from haywire.core.types.registry import TypeRegistry
|
|
21
|
+
from haywire.ui.panel.registry import PanelRegistry
|
|
22
|
+
from haywire.ui.widget.registry import WidgetRegistry
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@library(
|
|
26
|
+
file_watcher=True,
|
|
27
|
+
)
|
|
28
|
+
class Library(BaseLibrary):
|
|
29
|
+
"""Image library — image values, types and IO."""
|
|
30
|
+
|
|
31
|
+
def register_components(self):
|
|
32
|
+
"""Register the component folders with their registries."""
|
|
33
|
+
base_path = Path(__file__).parent
|
|
34
|
+
|
|
35
|
+
self.add_folder_to_registry(folder_path=str(base_path / "settings"), registry_cls=SettingsRegistry)
|
|
36
|
+
self.add_folder_to_registry(folder_path=str(base_path / "types"), registry_cls=TypeRegistry)
|
|
37
|
+
self.add_folder_to_registry(folder_path=str(base_path / "adapters"), registry_cls=AdapterRegistry)
|
|
38
|
+
self.add_folder_to_registry(folder_path=str(base_path / "widgets"), registry_cls=WidgetRegistry)
|
|
39
|
+
self.add_folder_to_registry(folder_path=str(base_path / "nodes"), registry_cls=NodeRegistry)
|
|
40
|
+
self.add_folder_to_registry(folder_path=str(base_path / "panels"), registry_cls=PanelRegistry)
|
|
41
|
+
|
|
42
|
+
def validate(self) -> bool:
|
|
43
|
+
return True
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Layout adapters: any image to a gray, RGB or RGBA image."""
|
|
2
|
+
|
|
3
|
+
from typing_extensions import override
|
|
4
|
+
|
|
5
|
+
from haywire.core.adapter.base import BaseAdapter, adapter
|
|
6
|
+
|
|
7
|
+
from haybale_image.types.image import IMAGE, IMAGE_GRAY, IMAGE_RGB, IMAGE_RGBA
|
|
8
|
+
from haybale_image.value import ImageValue, Layout, convert_layout
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _sample(layout: Layout) -> ImageValue:
|
|
12
|
+
import numpy as np
|
|
13
|
+
|
|
14
|
+
channels = {Layout.GRAY: (), Layout.RGB: (3,), Layout.RGBA: (4,)}[layout]
|
|
15
|
+
return ImageValue.from_array(np.zeros((2, 2, *channels), dtype=np.uint8))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@adapter(description="Convert an image to gray", converts_from=IMAGE, converts_to=IMAGE_GRAY)
|
|
19
|
+
class ImageToGrayAdapter(BaseAdapter):
|
|
20
|
+
"""Convert an image to one gray channel (luma of the colour channels)."""
|
|
21
|
+
|
|
22
|
+
@override
|
|
23
|
+
def convert(self, value: ImageValue) -> ImageValue:
|
|
24
|
+
return convert_layout(value, Layout.GRAY)
|
|
25
|
+
|
|
26
|
+
def get_test_value(self) -> ImageValue:
|
|
27
|
+
return _sample(Layout.RGB)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@adapter(description="Convert an image to RGB", converts_from=IMAGE, converts_to=IMAGE_RGB)
|
|
31
|
+
class ImageToRgbAdapter(BaseAdapter):
|
|
32
|
+
"""Convert an image to three colour channels, dropping transparency or repeating gray."""
|
|
33
|
+
|
|
34
|
+
@override
|
|
35
|
+
def convert(self, value: ImageValue) -> ImageValue:
|
|
36
|
+
return convert_layout(value, Layout.RGB)
|
|
37
|
+
|
|
38
|
+
def get_test_value(self) -> ImageValue:
|
|
39
|
+
return _sample(Layout.GRAY)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@adapter(description="Convert an image to RGBA", converts_from=IMAGE, converts_to=IMAGE_RGBA)
|
|
43
|
+
class ImageToRgbaAdapter(BaseAdapter):
|
|
44
|
+
"""Convert an image to colour plus transparency, fully opaque when it had none."""
|
|
45
|
+
|
|
46
|
+
@override
|
|
47
|
+
def convert(self, value: ImageValue) -> ImageValue:
|
|
48
|
+
return convert_layout(value, Layout.RGBA)
|
|
49
|
+
|
|
50
|
+
def get_test_value(self) -> ImageValue:
|
|
51
|
+
return _sample(Layout.RGB)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ImageToGrayAdapter
|
|
2
|
+
|
|
3
|
+
`haybale-image:adapter:ImageToGrayAdapter` · kind: adapter
|
|
4
|
+
|
|
5
|
+
Convert an image to gray
|
|
6
|
+
|
|
7
|
+
## Details
|
|
8
|
+
|
|
9
|
+
- **converts_from**: `haybale-image:type:IMAGE`
|
|
10
|
+
- **converts_to**: `haybale-image:type:IMAGE_GRAY`
|
|
11
|
+
- **priority**: `0`
|
|
12
|
+
|
|
13
|
+
## Notes
|
|
14
|
+
|
|
15
|
+
Convert an image to one gray channel (luma of the colour channels).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ImageToRgbAdapter
|
|
2
|
+
|
|
3
|
+
`haybale-image:adapter:ImageToRgbAdapter` · kind: adapter
|
|
4
|
+
|
|
5
|
+
Convert an image to RGB
|
|
6
|
+
|
|
7
|
+
## Details
|
|
8
|
+
|
|
9
|
+
- **converts_from**: `haybale-image:type:IMAGE`
|
|
10
|
+
- **converts_to**: `haybale-image:type:IMAGE_RGB`
|
|
11
|
+
- **priority**: `0`
|
|
12
|
+
|
|
13
|
+
## Notes
|
|
14
|
+
|
|
15
|
+
Convert an image to three colour channels, dropping transparency or repeating gray.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ImageToRgbaAdapter
|
|
2
|
+
|
|
3
|
+
`haybale-image:adapter:ImageToRgbaAdapter` · kind: adapter
|
|
4
|
+
|
|
5
|
+
Convert an image to RGBA
|
|
6
|
+
|
|
7
|
+
## Details
|
|
8
|
+
|
|
9
|
+
- **converts_from**: `haybale-image:type:IMAGE`
|
|
10
|
+
- **converts_to**: `haybale-image:type:IMAGE_RGBA`
|
|
11
|
+
- **priority**: `0`
|
|
12
|
+
|
|
13
|
+
## Notes
|
|
14
|
+
|
|
15
|
+
Convert an image to colour plus transparency, fully opaque when it had none.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Image Info
|
|
2
|
+
|
|
3
|
+
`haybale-image:node:ImageInfoNode` · kind: node
|
|
4
|
+
|
|
5
|
+
Reports the width, height, channel layout and bit depth of an image
|
|
6
|
+
|
|
7
|
+
## Ports
|
|
8
|
+
|
|
9
|
+
| id | direction | type | description |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `image` | inlet | `haybale-image:type:IMAGE` | Image to describe |
|
|
12
|
+
| `width` | outlet | `haywire-core:type:INT` | Width in pixels |
|
|
13
|
+
| `height` | outlet | `haywire-core:type:INT` | Height in pixels |
|
|
14
|
+
| `layout` | outlet | `haywire-core:type:STRING` | Channels: gray, rgb or rgba |
|
|
15
|
+
| `depth` | outlet | `haywire-core:type:INT` | Bits per channel of the source file, such as 8 or 16 |
|
|
16
|
+
|
|
17
|
+
## Notes
|
|
18
|
+
|
|
19
|
+
Reports the width, height, channel layout and bit depth of an `Image`.
|
|
20
|
+
|
|
21
|
+
- `Width`, `Height`: size in pixels.
|
|
22
|
+
- `Layout`: `gray`, `rgb` or `rgba`.
|
|
23
|
+
- `Depth`: bits per channel of the file the image was read from (8, 16 or 32).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Load Image
|
|
2
|
+
|
|
3
|
+
`haybale-image:node:LoadImageNode` · kind: node
|
|
4
|
+
|
|
5
|
+
Reads an image file from a volume
|
|
6
|
+
|
|
7
|
+
## Ports
|
|
8
|
+
|
|
9
|
+
| id | direction | type | description |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `path` | inlet | `haywire-core:type:FILE_PATH` | Image file to read |
|
|
12
|
+
| `progress.main` | config | `haywire-core:type:PROGRESS` | |
|
|
13
|
+
| `image` | outlet | `haybale-image:type:IMAGE` | The decoded image |
|
|
14
|
+
|
|
15
|
+
## Settings
|
|
16
|
+
|
|
17
|
+
| name | bag | default | description |
|
|
18
|
+
|---|---|---|---|
|
|
19
|
+
| `main` | progress | `PROGRESS(active=False, fraction=None, label='')` | |
|
|
20
|
+
|
|
21
|
+
## Notes
|
|
22
|
+
|
|
23
|
+
Reads an image file from a volume into an `Image`.
|
|
24
|
+
|
|
25
|
+
Gray files stay gray, files with transparency become RGBA and everything else
|
|
26
|
+
is RGB. The camera's rotation (EXIF orientation) is applied to the pixels on
|
|
27
|
+
load, because OpenCV's reader ignores it.
|
|
28
|
+
16-bit and float files are read at full precision; see Image Info's `Depth`.
|
|
29
|
+
|
|
30
|
+
The Loading bar shows while the file is read and decoded.
|
|
31
|
+
|
|
32
|
+
The node reports an error naming the file when it is missing or is not an
|
|
33
|
+
image, and when `Path` leads to a volume that is not defined on this machine.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
For Each File → Load Image → Image Info
|
|
37
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Save Image
|
|
2
|
+
|
|
3
|
+
`haybale-image:node:SaveImageNode` · kind: node
|
|
4
|
+
|
|
5
|
+
Writes an image to a file in a volume, in the format its extension names
|
|
6
|
+
|
|
7
|
+
## Ports
|
|
8
|
+
|
|
9
|
+
| id | direction | type | description |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `exec` | inlet | `haywire-core:type:EXEC` | Saves the image |
|
|
12
|
+
| `image` | inlet | `haybale-image:type:IMAGE` | Image to save |
|
|
13
|
+
| `path` | inlet | `haywire-core:type:FILE_PATH` | File to write; its extension picks the format |
|
|
14
|
+
| `if_exists` | config | `haywire-core:type:STRING` | When the file exists: overwrite, skip, or unique-suffix (adds a number) |
|
|
15
|
+
| `depth` | config | `haywire-core:type:STRING` | Bits per channel: source keeps the image's own, or 8, 16, 32 |
|
|
16
|
+
| `progress.main` | config | `haywire-core:type:PROGRESS` | |
|
|
17
|
+
| `next` | outlet | `haywire-core:type:EXEC` | Runs after saving |
|
|
18
|
+
| `saved` | outlet | `haywire-core:type:FILE_PATH` | The file written, or the one skipped |
|
|
19
|
+
|
|
20
|
+
## Settings
|
|
21
|
+
|
|
22
|
+
| name | bag | default | description |
|
|
23
|
+
|---|---|---|---|
|
|
24
|
+
| `compression` | png | `None` | Compression of saved PNG files, from 0 (fastest) to 9 (smallest); never loses detail |
|
|
25
|
+
| `quality` | jpeg | `None` | Quality of saved JPEG files, from 0 (smallest) to 100 (best) |
|
|
26
|
+
| `quality` | webp | `None` | Quality of saved WebP files, from 0 (smallest) to 100 (best) |
|
|
27
|
+
| `lossless` | webp | `None` | Save WebP files without losing detail; WebP quality is then ignored |
|
|
28
|
+
| `compression` | tiff | `None` | Compression of saved TIFF files; none of them loses detail |
|
|
29
|
+
| `quality` | avif | `None` | Quality of saved AVIF files, from 0 (smallest) to 100 (best) |
|
|
30
|
+
| `main` | progress | `PROGRESS(active=False, fraction=None, label='')` | |
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
Writes `Image` to the file at `Path`, in the format its extension names.
|
|
35
|
+
|
|
36
|
+
Known extensions: `.png`, `.jpg`/`.jpeg`, `.webp`, `.tif`/`.tiff`, `.bmp`, `.gif`,
|
|
37
|
+
`.tga`, `.avif`. The file appears complete or not at all; a half-written file is
|
|
38
|
+
never left behind.
|
|
39
|
+
|
|
40
|
+
- `If Exists`: what to do when the file is already there. `overwrite` replaces
|
|
41
|
+
it, `skip` keeps it and writes nothing, `unique-suffix` saves beside it as
|
|
42
|
+
`name_1.png`, `name_2.png`, and so on.
|
|
43
|
+
- `Depth`: `source` keeps the image's own bit depth; `8`, `16` and `32` (float)
|
|
44
|
+
ask for that depth. A format that cannot store it gets the deepest it can
|
|
45
|
+
(JPEG is always 8-bit, PNG at most 16-bit). 16-bit and float saves drop the
|
|
46
|
+
image's ICC profile and EXIF block.
|
|
47
|
+
|
|
48
|
+
`Saved` is the file that now holds the image: the suffixed name for
|
|
49
|
+
`unique-suffix`, and the existing file for `skip`.
|
|
50
|
+
|
|
51
|
+
The quality and compression settings default to the library's *Image* settings;
|
|
52
|
+
change them here for this node only. Only the settings of the format `Path` names
|
|
53
|
+
are shown.
|
|
54
|
+
|
|
55
|
+
The Saving bar shows while the file is encoded and written.
|
|
56
|
+
|
|
57
|
+
The folder must already exist; add Create Folder before Save Image to make it.
|
|
58
|
+
An empty image, an unknown extension and a volume that is not defined on this
|
|
59
|
+
machine are reported as errors.
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
For Each File → Load Image → … → Save Image (Path = Output Path)
|
|
63
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# View Image
|
|
2
|
+
|
|
3
|
+
`haybale-image:node:ViewImageNode` · kind: node
|
|
4
|
+
|
|
5
|
+
Shows an image on the node, as a live stream or as a still picture
|
|
6
|
+
|
|
7
|
+
## Ports
|
|
8
|
+
|
|
9
|
+
| id | direction | type | description |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `exec` | inlet | `haywire-core:type:EXEC` | Shows the image |
|
|
12
|
+
| `image` | inlet | `haybale-image:type:IMAGE` | Image to show |
|
|
13
|
+
| `next` | outlet | `haywire-core:type:EXEC` | Runs after showing |
|
|
14
|
+
| `image_out` | outlet | `haybale-image:type:IMAGE` | The same image, passed on |
|
|
15
|
+
|
|
16
|
+
## Settings
|
|
17
|
+
|
|
18
|
+
| name | bag | default | description |
|
|
19
|
+
|---|---|---|---|
|
|
20
|
+
| `mode` | viewer | `'still'` | stream for images that change often (a camera); still for large, rarely changing ones |
|
|
21
|
+
| `enlarge` | viewer | `3.0` | How many times wider the view gets when a still image is clicked |
|
|
22
|
+
| `zoom` | viewer | `1.0` | How many times the enlarged view's width the image shows; 1 fits it |
|
|
23
|
+
|
|
24
|
+
## Notes
|
|
25
|
+
|
|
26
|
+
Shows `Image` on the node and passes it on to `Image Out`.
|
|
27
|
+
|
|
28
|
+
- `Mode`: `stream` for images that change many times a second, such as a camera;
|
|
29
|
+
`still` for large images that change rarely, such as a loaded file. A still
|
|
30
|
+
image keeps its transparency.
|
|
31
|
+
|
|
32
|
+
Click a still image to enlarge the view: it gets `Enlarge view` times wider and
|
|
33
|
+
takes the image's shape, and the image shows `Zoom image` times the view's width
|
|
34
|
+
(1 fits it). Drag inside it to move around the image; click again to go back.
|
|
35
|
+
|
|
36
|
+
The view appears once `Image` is connected.
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
Load Image → View Image (Mode = still)
|
|
40
|
+
```
|