Built-in sandbox SHIM: a Pillow (PIL)-compatible PIL package for the model's
Python sandbox, backed by the JVM's Java2D / ImageIO image stack. No CPython
Pillow wheel ships in the sandbox; this extension contributes a
:ext/sandbox-shims entry that env-python/build-agent-context installs into
every sandbox Context (main + every sub_loop fork): the host bridge callables
are wired onto the globals, then the Python preamble publishes a PIL package
(with Image, ImageDraw, ImageFilter, ImageOps, ImageColor,
ImageEnhance, ImageChops, ImageFont, ImageMath submodules) into
sys.modules (so from PIL import Image works) and staples them onto builtins.
Images live HOST-side as BufferedImages in a per-JVM registry keyed by an
integer handle; the Python Image object is a thin handle wrapper. All pixel
ops, drawing, filtering, geometry and codec work happen on the JVM; only small
metadata vectors and base64 blobs cross the strings-only boundary. Mirrors the
shim-matplotlib Java2D approach and reuses mpl-capture/record-attachment!
so Image.show() surfaces the image inline as a session attachment.
Built-in sandbox SHIM: a Pillow (PIL)-compatible `PIL` package for the model's Python sandbox, backed by the JVM's Java2D / ImageIO image stack. No CPython Pillow wheel ships in the sandbox; this extension contributes a `:ext/sandbox-shims` entry that `env-python/build-agent-context` installs into every sandbox Context (main + every `sub_loop` fork): the host bridge callables are wired onto the globals, then the Python preamble publishes a `PIL` package (with `Image`, `ImageDraw`, `ImageFilter`, `ImageOps`, `ImageColor`, `ImageEnhance`, `ImageChops`, `ImageFont`, `ImageMath` submodules) into `sys.modules` (so `from PIL import Image` works) and staples them onto builtins. Images live HOST-side as `BufferedImage`s in a per-JVM registry keyed by an integer handle; the Python `Image` object is a thin handle wrapper. All pixel ops, drawing, filtering, geometry and codec work happen on the JVM; only small metadata vectors and base64 blobs cross the strings-only boundary. Mirrors the `shim-matplotlib` Java2D approach and reuses `mpl-capture/record-attachment!` so `Image.show()` surfaces the image inline as a session attachment.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |