Skip to content

Fix/issue 47 serialization#61

Open
shreyasavadatti wants to merge 1 commit into
moth-quantum:sourcefrom
shreyasavadatti:fix/issue-47-serialization
Open

Fix/issue 47 serialization#61
shreyasavadatti wants to merge 1 commit into
moth-quantum:sourcefrom
shreyasavadatti:fix/issue-47-serialization

Conversation

@shreyasavadatti

@shreyasavadatti shreyasavadatti commented Jun 8, 2026

Copy link
Copy Markdown

Fixes #47

The issue was that every brush stroke was saving PNG files to disk (_input.png and _output.png) which piled up and never got cleaned, especially bad with large images.

Instead of passing file paths through the JSON, I changed it so the image data is base64-encoded and embedded directly in the stroke JSON. Java encodes the canvas pixels before calling Python, Python decodes it, runs the algorithm, then encodes the result back the same way. Java reads the result out of the JSON too. No intermediate PNG files get written at all.

Tested with all four brushes, Apply to Canvas, and Undo/Redo still work correctly.

Closes #47

…loses moth-quantum#47)

Previously, Java wrote current.png / original.png to disk and passed
file paths to Python via JSON for every brush stroke. Python read those
PNGs, ran the quantum algorithm, and wrote output.png — files accumulated
indefinitely, especially painful with high-resolution canvases.

This PR embeds pixel data directly in the JSON payload as a base64-encoded
RGBA byte string (matching the image_rgba format documented in template.json),
and returns the result the same way. No intermediate PNG files are written
for stroke processing.

Changes:
- effect/apply_effect.py: decode image_rgba base64 from JSON instead of
  Image.open(path); return result as base64 instead of writing output.png
- src/StrokeManager.java: serialize canvas pixels to base64 in JSON instead
  of saving _input.png; decode result from JSON instead of loadImage();
  remove _input.png and _output.png from deleteStroke() cleanup
@shreyasavadatti shreyasavadatti changed the base branch from dist to source June 13, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serialization and what's next? Improve communication between different language stack

1 participant