Fix/issue 47 serialization#61
Open
shreyasavadatti wants to merge 1 commit into
Open
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #47
The issue was that every brush stroke was saving PNG files to disk (
_input.pngand_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