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

Polygon discrepancies pdf vs figure #455

Open
pwalczysko opened this issue Feb 4, 2022 · 4 comments
Open

Polygon discrepancies pdf vs figure #455

pwalczysko opened this issue Feb 4, 2022 · 4 comments

Comments

@pwalczysko
Copy link
Member

See the figure on https://outreach.openmicroscopy.org/figure/file/173681/ . When exported as pdf, the lines in the figure are much less than on the pdf. Also, they protrude into the canvas on the pdf. Note that the images were intentionally rendered black just for the purpose of not exposing the figure images publicly before taking the screenshots below.

PDF:

Screenshot 2022-02-04 at 13 49 56

Figure:
Screenshot 2022-02-04 at 13 49 00

@pwalczysko
Copy link
Member Author

cc @will-moore

@Tom-TBT
Copy link
Contributor

Tom-TBT commented Dec 23, 2022

Looking into that issue, I haven't got a solution yet, but I thought writing down here what I figured before going on holiday.

First, the issue goes beyond. Shapes are checked whether inside the image or not, by looking at each point composing them. For example, if a square's corners are all outside the image but an edge still passes on top, the shape won't be displayed in the PDF:

# Don't draw if all points outside panel viewport

Example with a polygon on two views of the same image+ROI:
OMERO.figure:
image

PDF export:
image

Regarding the shapes going outside of the image, this is because the drawing happens at the canvas level for PDF, independently from the image pasting (while TIFF has the shape pasted first on the image, then the modified image is pasted on the canvas):

def add_panels_to_page(self, panels_json, image_ids, page):

Now I've been looking for a way to restrict PDF drawing to the boundaries of an image, but no success
(keywords: reportlab canvas drawPath mask restrict crop)
We could bother to calculate "new points" to be drawn, but that will bring many more issues when filling shapes (not mentioning text labels).

Instead, why not use the TIFF approach, and modify the images before drawing them on the PDF? The shape wouldn't be in the vector format anymore. But the resolution is supposed to match that of the image anyway, or?
I found this comment, why is that?

# ... but for PDF we have to add shapes to the whole PDF page

@will-moore
Copy link
Member

@Tom-TBT Thanks for your input on this issue.

That comment: # ... but for PDF we have to add shapes to the whole PDF page reflects the approach that is currently taken, where we don't "paint" the ROIs onto the shapes for PDFs, but instead we add vector shapes to the PDF page.

I guess we could do as use suggest and paint the Shapes onto the panels as we do for TIFF export. That should fix this issue, but I wonder if many users would mind? How useful it is to have the Shapes as separate vectors on a PDF? Do users ever open the PDF figures in e.g. Illustrator and edit those Shapes? In cases where the panel is low resolution, they might not appear so nice if we paint them onto the images?

@Tom-TBT
Copy link
Contributor

Tom-TBT commented Feb 8, 2023

Found #330, a suggestion from you to finalize PDF figure exports in a postscript editor.
So removing completely the export of vectors could indeed be frustrating as it's an "official workaround"

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

No branches or pull requests

3 participants