PIPELINE. Host-side pixel work, and its composition with GIMP.
This is what the optional Python port is FOR. GIMP has no procedure for
learned background removal, and the reference project's answer is
bg_remove_iterative.py: sixteen kilobytes that samples corner colours, runs
select_by_color at a threshold, measures what it removed, adjusts the
threshold, and goes round again. It is a careful piece of work and it is
fighting the tool. rembg is one call and a segmentation model.
The composition is export, operate, re-open:
GIMP ---export_image---> PNG on disk PNG ---rembg/PIL-----> PNG on disk PNG ---open_image----> GIMP
Two round trips through the plugin and one Python call. Note that this reads
well with hive-gimp.transport.python, where the GIMP socket and the pixel
work happen in the SAME interpreter and the intermediate file never leaves
Python's own view of the filesystem.
Every operation degrades honestly: without the port they return an error
naming :python/no-libpython and the remediation, never a silent no-op.
PIPELINE. Host-side pixel work, and its composition with GIMP. This is what the optional Python port is FOR. GIMP has no procedure for learned background removal, and the reference project's answer is bg_remove_iterative.py: sixteen kilobytes that samples corner colours, runs `select_by_color` at a threshold, measures what it removed, adjusts the threshold, and goes round again. It is a careful piece of work and it is fighting the tool. `rembg` is one call and a segmentation model. The composition is export, operate, re-open: GIMP ---export_image---> PNG on disk PNG ---rembg/PIL-----> PNG on disk PNG ---open_image----> GIMP Two round trips through the plugin and one Python call. Note that this reads well with `hive-gimp.transport.python`, where the GIMP socket and the pixel work happen in the SAME interpreter and the intermediate file never leaves Python's own view of the filesystem. Every operation degrades honestly: without the port they return an error naming `:python/no-libpython` and the remediation, never a silent no-op.
(available? host-python)True when the host-side Python port can run these operations.
True when the host-side Python port can run these operations.
(image-info host-python path)Width, height, mode and format of an image file, via PIL.
Useful next to gimp_get_image_metadata, which describes what GIMP has
OPEN. This describes a file on disk, including one GIMP has not opened and
one this library just wrote.
Width, height, mode and format of an image file, via PIL. Useful next to `gimp_get_image_metadata`, which describes what GIMP has OPEN. This describes a file on disk, including one GIMP has not opened and one this library just wrote.
(remove-background host-python in-path out-path)Remove the background of in-path, writing a transparent PNG to out-path.
One rembg call, made on the Python side: read, remove, write all happen in the interpreter, so the image bytes cross the bridge zero times. The alternative, marshalling the buffer into the JVM and back, would be slower and would turn a segmentation result into a byte array for no reason.
The model downloads on first use, so the first invocation is slow and the rest are not. That is rembg's behaviour and it is surfaced rather than hidden behind a timeout that would make it look like a hang.
Remove the background of `in-path`, writing a transparent PNG to `out-path`. One rembg call, made on the Python side: read, remove, write all happen in the interpreter, so the image bytes cross the bridge zero times. The alternative, marshalling the buffer into the JVM and back, would be slower and would turn a segmentation result into a byte array for no reason. The model downloads on first use, so the first invocation is slow and the rest are not. That is rembg's behaviour and it is surfaced rather than hidden behind a timeout that would make it look like a hang.
(remove-background-in-gimp transport host-python)(remove-background-in-gimp transport
host-python
{:keys [image-index] :or {image-index 0}})Export the current GIMP image, remove its background, and open the result.
The workflow bg_remove_iterative.py exists to approximate, done in one pass by a model that was trained for it.
Returns an Outcome whose value names both temp files, so a caller can
inspect the intermediate when the result is not what they expected. The
files are marked delete-on-exit rather than removed eagerly, for the same
reason.
Export the current GIMP image, remove its background, and open the result. The workflow bg_remove_iterative.py exists to approximate, done in one pass by a model that was trained for it. Returns an `Outcome` whose value names both temp files, so a caller can inspect the intermediate when the result is not what they expected. The files are marked delete-on-exit rather than removed eagerly, for the same reason.
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 |