Browser based export - #12
Draft
will-moore wants to merge 18 commits into
Draft
will-moore wants to merge 18 commits into
will-moore wants to merge 18 commits into
Conversation
✅ Deploy Preview for ome-figure ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
will-moore
marked this pull request as ready for review
September 18, 2026 09:30
Member
|
Conflicting PR. Removed from build OMERO-plugins-push#82. See the console output for more details.
--conflicts |
will-moore
marked this pull request as draft
September 22, 2026 15:06
will-moore
force-pushed
the
browser_based_export
branch
from
September 25, 2026 13:20
d84f734 to
4de24d2
Compare
This branch has not been deployed
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.
Using jsPDF to create a PDF in the browser (with GitHub Co-pilot's help!)
Test sample: https://deploy-preview-12--ome-figure.netlify.app/?file=https://raw.githubusercontent.com/will-moore/figure/refs/heads/figure_json_from_gist/sample_figures/ngff_images_figure.json
This is a major rewrite of the Figure_To_Pdf.py script into JavaScript.
Follow-up work:
Outline of changes:
Even before the conversion of python script to JavaScript, I removed all the image rendering logic and other OMERO code from the python script and instead used the images that we have already rendered in the browser. These were included in the
figure.jsonpassed to the script in the form ofpanel.src = "data:url...".In order to have these available to the figure-model, they are updated in the panel-model when the image is re-rendered. To reduce the size of the JSON passed to the pdf generation, I also implemented the cropping, rotation etc first, then just pass the viewport region to the pdf script. (I was also trying to make the export script a bit simpler so that it was easier to convert, but I probably didn't need to bother since AI handled the rewrite easily)
When images are rendered from OMERO, the
srcdata should be included in the panel model in the same way, so the export step is the same for OME-Zarr and OMERO images.The cropping of the rendered panel 'src' data happens at export time. As before, in the app page we actually render an image larger than the viewport so that the user can pan the image etc. For small images (< 3k) we render the whole image. For Big images we render a region that is 50% larger than the viewport.
So, there may be some bugs in the panel rendering - needs testing
Also need to test Big images where the smallest resolution is still very large. These images have been problematic in the past. There may be issues when manipulating large images on a canvas.
So, the
Figure_To_Pdf.pyscript has had some changes to it, then I copied the minimal PDF generation code from it into a new scriptexport_script.pyto serve as the basis for AI conversion to JavaScript. I'm not sure if we want to keep either of these python scripts long-term. Are they still useful for anything?The
Figure_To_Pdf.pyscript contains TIFF export logic that hasn't yet been converted to JavaScript. However, it may be easier to have AI use the new JavaScript PDF generation as a template forpngexport, rather than the python code.TODOS (this PR):