Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional export functionality #306

Merged
merged 17 commits into from
Sep 24, 2018
Merged

Conversation

knabar
Copy link
Member

@knabar knabar commented Jul 10, 2018

This PR includes additional functionality for the PDF/TIFF export:

  • Shape fills (fully transparent when not given)
  • Alpha channel for stroke and fill colors (defaulting to fully opaque when not given)
  • Rotated rectangles (by processing rectangles as a polygon)
  • Point shapes (as small circles processed as ellipses)
  • Shape labels

None of these changes should impact the current export behavior for a given figure, though I need to do some more thorough testing.

Especially shape label rendering will need some more work, but opening the PR now for early review.

@knabar knabar force-pushed the export-functionality branch 3 times, most recently from f2155e3 to 5c7d8b3 Compare July 23, 2018 12:06
@jburel jburel added this to the 4.0.1 milestone Jul 25, 2018
@jburel
Copy link
Member

jburel commented Aug 3, 2018

Comparing both web-latest and web-merge
No obvious regression in the exported figure
I noticed a problem exporting as TIFF see screenshot (left export, right figure)
export_as_tiff


def draw_polyline(self, shape):
self.draw_polygon(shape, False)

def draw_ellipse(self, shape):
stroke_width = shape['strokeWidth']
c = self.panel_to_page_coords(shape['x'], shape['y'])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that means that we wont' be able to handle shapes covering partially the image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's always been the case with PDF export. Shapes that extend outside of the cropped image panel are drawn on the page without being confined to the panel that they come from. Haven't found a way to be able to work around that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification @will-moore

@will-moore
Copy link
Member

Seems that the issue @jburel noticed above is due to this PR. Tried exporting same figure with script from origin/master (left) and then from this branch (right). NB: also noticed a truncation of the purple Polylline.

screen shot 2018-08-06 at 10 28 09

@knabar
Copy link
Member Author

knabar commented Aug 6, 2018 via email

@jburel jburel removed this from the 4.0.1 milestone Aug 27, 2018
@knabar knabar force-pushed the export-functionality branch from 8ce57b3 to 1001d3a Compare August 30, 2018 13:24
@knabar
Copy link
Member Author

knabar commented Aug 30, 2018

Rebased on top of 4.0.1 and fixed the offset/cropping issue when drawing polygons

@jburel
Copy link
Member

jburel commented Sep 12, 2018

@knabar is it ready for review?

@knabar
Copy link
Member Author

knabar commented Sep 12, 2018

@jburel Yes, apologies for not explicitly stating so

@will-moore
Copy link
Member

This has fixed the issue we were seeing above. The only problem I'm seeing now is that the rectangle corners are rounded in TIFF export because of the way that we're drawing polygons.

For rotated rectangles (which we don't yet support in the web UI) it may be harder find a workaround so I guess it's OK to use the polygon method, but if there's no rotation then I think it would be nice to preserve the current behaviour.

I also tested with a rotated image (not rotated rectangles) and it's working fine:

screen shot 2018-09-17 at 10 32 47

@knabar
Copy link
Member Author

knabar commented Sep 17, 2018

@will-moore Thanks. I'll check out the rectangle issue to see if there's an easy fix for both unrotated and rotated.

@knabar
Copy link
Member Author

knabar commented Sep 17, 2018

Apparently yesterday a PR was merged into Pillow to draw nicer polyline joints, but they chose rounded joints also: python-pillow/Pillow#3250

@knabar
Copy link
Member Author

knabar commented Sep 17, 2018

@will-moore @jburel I changed rectangle drawing for Pillow back to a custom method to get squared corners. Ready for another review.

screen shot 2018-09-17 at 17 45 50

@will-moore
Copy link
Member

This is working nicely for me now.
But travis is complaining:

./omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py:669:5: E303 too many blank lines (2)

Otherwise, good to merge.

@knabar
Copy link
Member Author

knabar commented Sep 19, 2018

@will-moore Fixed the blank line

@will-moore
Copy link
Member

This is also working on web-dev-merge now too. Good to merge.

@jburel jburel merged commit 6c022cd into ome:master Sep 24, 2018
@knabar knabar deleted the export-functionality branch September 24, 2018 14:22
@jburel jburel added this to the 4.0.2 milestone Oct 2, 2018
@will-moore will-moore mentioned this pull request Aug 29, 2024
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.

3 participants