Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add URL support for images in PDF backend#23454

Draft
oscargus wants to merge 1 commit intomatplotlib:mainfrom
oscargus:pdfimageurl
Draft

Add URL support for images in PDF backend#23454
oscargus wants to merge 1 commit intomatplotlib:mainfrom
oscargus:pdfimageurl

Conversation

@oscargus
Copy link
Member

@oscargusoscargus commentedJul 20, 2022
edited
Loading

PR Summary

Related to#23152

Currently, this doesn't work with a transform. If a standard transform is used, as inhttps://matplotlib.org/stable/gallery/images_contours_and_fields/affine_image.html it works, but the area is the "outline rectangle", rather than the exact area.

For transforms withinterpolation='none' it doesn't work at all. However, for a plain image or a transformed withinterpolation='none' it works well.

Note that one cannot use composite images (plt.rcParams['image.composite_image'] must beFalse) for this to work as the composite image doesn't have an URL set.

There should be a release note outlining the limitations, but maybe I can figure out how to improve it slightly before that...

(This also includes a minor refactoring.)

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@oscargus
Copy link
MemberAuthor

Basically, there are two things that can/should be fixed.

  1. When performing a transform, I would like to know the corners of the actual image contents, not the "outline rectangle", the red part in
    image

However, it seems like all one has access to at this stage is the NumPy array, where the values are already transformed?

When performing a transform using the PDF transform mechanism (typically triggered when `interpolation='none'), I need something similar that determined the corners of the actual image based on the six values of the PDF transformation.

For the latter case it is just a matter of sorting out the trigonometry.

@oscargus
Copy link
MemberAuthor

oscargus commentedJul 21, 2022
edited
Loading

Case 2 solved.

Remaining problems:

  • Case 1 above (I think one way is to try to detect where alpha = 0 and based on that try to detect the actual corners, but I do not think it that I will be able to do that in the near future
  • Images that are clipped will be clickable even on the clipped parts. This is not trivial to fix as one need "QuadPoints", i.e. skewed and rotated rectangles, so in many cases this will end up with multiple QuadPoints.

So for now I am pretty happy with it for now.

@oscargusoscargusforce-pushed thepdfimageurl branch 4 times, most recently fromf6e34a6 tod401c1cCompareJuly 21, 2022 12:44
@oscargusoscargus marked this pull request as ready for reviewJuly 21, 2022 12:44
Copy link
Member

@QuLogicQuLogic left a comment

Choose a reason for hiding this comment

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

Have not read the code yet.

The PDF backend can now generate clickable images if a URL is provided to the
image. There are a few limitations worth noting though:

* If parts of the image are clipped, the non-visible parts are still clickable.
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean, if you zoom in on the image, parts outside the Axes will be clickable?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes. It is sort of easy to fix for non-transformed images (if there is a way to get the Axes extents from the gc(?). But for transformed it is much harder.

(I think the same holds for texts.)

Comment on lines +8 to +10
* If there are transforms applied to the image, the whole enclosing rectangle
is clickable. However, if you use ``interpolation='none'`` for the image,
only the transformed image area is clickable (depending on viewer support).
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I'm confused about what this means.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

First sentence: Basically, the image with the hand drawn "rectangle" above is clickable. Probably there is a better wording for it.

Second sentence: if you rely on the PDF transform (i.e. set interpolation='none' and possibly a few more conditions) the clickable area is the image. Bracket part: not all PDF viewers support that and will fall back on the red rectangle.

@oscargusoscargus marked this pull request as draftJuly 23, 2022 14:24
@oscargus
Copy link
MemberAuthor

OK, I know how to sort out the clickable outside of Axes-thing for non-transformed images (in theory for transformed as well, but will have to think a bit further regarding how many different cases there are and how to deal with them).

@github-actions
Copy link

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@github-actionsgithub-actionsbot added the status: inactiveMarked by the “Stale” Github Action labelDec 15, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@QuLogicQuLogicQuLogic left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

backend: pdfstatus: inactiveMarked by the “Stale” Github Action

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@oscargus@QuLogic

[8]ページ先頭

©2009-2026 Movatter.jp