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

Get error from page.get_pixmap() in version 1.18.18 #1266

Closed
Augus1999 opened this issue Sep 16, 2021 · 6 comments
Closed

Get error from page.get_pixmap() in version 1.18.18 #1266

Augus1999 opened this issue Sep 16, 2021 · 6 comments
Assignees
Labels

Comments

@Augus1999
Copy link

Describe the bug

Get error AttributeError: 'Pixmap' object has no attribute 'samples_mv' when using method page.get_pixmap()

To Reproduce

The code I used is

page_pixmap = page.get_pixmap(
        matrix=fitz.Matrix(1.0, 1.0),
        clip=True,
    )

This worked well in old PyMuPDF versions.

System configuration

  • Operating system : Windows 10 21H1 64-bit
  • Python version: Python 3.9.7 64-bit
  • PyMuPDF version==1.18.18 installed from wheel
@JorjMcKie
Copy link
Collaborator

There is indeed an error: the two attributes Pixmap.samples_mv, Pixmap.samples_ptr are not correctly set by .get_pixmap()` methods.
But the pixmap does get created in any case I tested.

@JorjMcKie
Copy link
Collaborator

JorjMcKie commented Sep 16, 2021

No, sorry, this error is a bit more serious. I think I need to submit a hotfix 😒.

@Augus1999
Copy link
Author

Hi, I do find self.samples_mv and self.samples_ptr in __init__ method of Pixmap, so I can't understand why the error occurs. I changed line 6791 of fitz.py into return bytes(self._samples_mv()) and Pixmap.samples works 😶.

@JorjMcKie
Copy link
Collaborator

Well, I do understand - a stupid error.
I need to do these assignments as well, when pixmaps get created for pages, annotations and DisplayLists, which I forgot.
So the result of page.get_pixmap()does have method pix._samples_mv(), but the assignment pix.samples_mv = pix._samples_mv() was not made.
Because this is the most frequent way of creatng pixmaps, I do need to publish a hotfix ...

@JorjMcKie
Copy link
Collaborator

I changed line 6791 of fitz.py into return bytes(self._samples_mv()) and Pixmap.samples works 😶.

good job btw

JorjMcKie added a commit that referenced this issue Sep 16, 2021
@JorjMcKie
Copy link
Collaborator

Just published v1.18.19 to PyPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants