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

Fix broken link in README.md #2084

Closed
wants to merge 1 commit into from

Conversation

djsamseng
Copy link

Comparing the old examples/image-maintaince.py with the new examples/edit-images/edit.py are all changes to the documentation or updating to the new API which replaced camel casing with underscores

diff -w old.py new.py
1,2d0
< # -*- coding: utf-8 -*-
<
4,11c2,4
< @created: 2020-08-05 13:00:00
< @author: Jorj X. McKie
< Let the user select a PDF file to maintain its images.
< Dependencies:
< PyMuPDF v1.17.5, wxPython Phoenix version
< License:
<  GNU GPL 3.x, GNU AFFERO GPL 3
< Copyright:
---
> Edit images in a PDF document
> -------------------------------------------------------------------------------
> License: GNU AFFERO GPL 3
12a6,11
> Usage
> -----
> python edit.py
> Dependencies
> ------------
> PyMuPDF v1.17.5, wxPython Phoenix version
13a13
>
136c136
<     img_rect = page.getImageBbox(img)
---
>     img_rect = page.get_image_bbox(img)
148c148
<     if img_rect.isInfinite:
---
>     if img_rect.is_infinite:
157,158c157,158
<     for xref in page.getContents():
<         cont = doc.xrefStream(xref)
---
>     for xref in page.get_contents():
>         cont = doc.xref_stream(xref)
222c222
<     mat_test = calc_matrix(1, 1, img_rect * ~page.transformationMatrix, rotate=deg)
---
>     mat_test = calc_matrix(1, 1, img_rect * ~page.transformation_matrix, rotate=deg)
232d231
<
236c235
<     img_list = [img[-3] for img in page.getImageList(True) if img[-1] == 0]
---
>     img_list = [img[-3] for img in page.get_images(True) if img[-1] == 0]
280c279
<         if self.doc.needsPass:  # check password protection
---
>         if self.doc.needs_pass:  # check password protection
282c281
<         if self.doc.isEncrypted:  # quit if we cannot decrypt
---
>         if self.doc.is_encrypted:  # quit if we cannot decrypt
694c693
<         page = min(page, self.doc.pageCount)  # cannot go beyond last page
---
>         page = min(page, self.doc.page_count)  # cannot go beyond last page
742c741
<         tar_rect = new_rect * ~page.transformationMatrix
---
>         tar_rect = new_rect * ~page.transformation_matrix
745c744
<         cont = bytearray(self.doc.xrefStream(xref))  # modifyable version!
---
>         cont = bytearray(self.doc.xref_stream(xref))  # modifyable version!
750c749
<         self.doc.updateStream(xref, bytes(cont))  # rewrite stream
---
>         self.doc.update_stream(xref, bytes(cont))  # rewrite stream
761d759
<
776c774
<         tar_rect = rect * ~page.transformationMatrix
---
>         tar_rect = rect * ~page.transformation_matrix
779c777
<         cont = bytearray(self.doc.xrefStream(xref))  # modifyable version!
---
>         cont = bytearray(self.doc.xref_stream(xref))  # modifyable version!
781c779
<         self.doc.updateStream(xref, bytes(cont))
---
>         self.doc.update_stream(xref, bytes(cont))
784,785c782,783
<         if not page._isWrapped:
<             page.wrapContents()
---
>         if not page.is_wrapped:
>             page.wrap_contents()
787c785
<         page.cleanContents()
---
>         page.clean_contents()
808c806
<         cont = bytearray(self.doc.xrefStream(xref))  # modifyable version!
---
>         cont = bytearray(self.doc.xref_stream(xref))  # modifyable version!
810,811c808,809
<         self.doc.updateStream(xref, bytes(cont))
<         page.cleanContents()
---
>         self.doc.update_stream(xref, bytes(cont))
>         page.clean_contents()
843c841
<         if self.doc.needsPass or not self.doc.can_save_incrementally():
---
>         if self.doc.needs_pass or not self.doc.can_save_incrementally():
852c850
<         if self.doc.needsPass or not self.doc.can_save_incrementally():
---
>         if self.doc.needs_pass or not self.doc.can_save_incrementally():
862d859
<         self.doc._delXmlMetadata()
883c880
<             page.insertImage(r, filename=path)
---
>             page.insert_image(r, filename=path)
1029c1026
<         if not rect.isInfinite:
---
>         if not rect.is_infinite:
1118c1115
<         pix = page.getPixmap(matrix=self.zoom, alpha=False)
---
>         pix = page.get_pixmap(matrix=self.zoom, alpha=False)
1143c1140
<             if self.doc.isEncrypted:
---
>             if self.doc.is_encrypted:

Comparing the [old examples/image-maintaince.py](https://github.com/pymupdf/PyMuPDF-Utilities/blob/ceb27639b6a7e1057178d448c5fdf7bc9d357406/examples/image-maintenance.py) with [the new examples/edit-images/edit.py](https://github.com/pymupdf/PyMuPDF-Utilities/blob/master/examples/edit-images/edit.py) are all changes to the documentation or updating to the new API which replaced camel casing with underscores

```bash
diff -w old.py new.py
1,2d0
< # -*- coding: utf-8 -*-
<
4,11c2,4
< @created: 2020-08-05 13:00:00
< @author: Jorj X. McKie
< Let the user select a PDF file to maintain its images.
< Dependencies:
< PyMuPDF v1.17.5, wxPython Phoenix version
< License:
<  GNU GPL 3.x, GNU AFFERO GPL 3
< Copyright:
---
> Edit images in a PDF document
> -------------------------------------------------------------------------------
> License: GNU AFFERO GPL 3
12a6,11
> Usage
> -----
> python edit.py
> Dependencies
> ------------
> PyMuPDF v1.17.5, wxPython Phoenix version
13a13
>
136c136
<     img_rect = page.getImageBbox(img)
---
>     img_rect = page.get_image_bbox(img)
148c148
<     if img_rect.isInfinite:
---
>     if img_rect.is_infinite:
157,158c157,158
<     for xref in page.getContents():
<         cont = doc.xrefStream(xref)
---
>     for xref in page.get_contents():
>         cont = doc.xref_stream(xref)
222c222
<     mat_test = calc_matrix(1, 1, img_rect * ~page.transformationMatrix, rotate=deg)
---
>     mat_test = calc_matrix(1, 1, img_rect * ~page.transformation_matrix, rotate=deg)
232d231
<
236c235
<     img_list = [img[-3] for img in page.getImageList(True) if img[-1] == 0]
---
>     img_list = [img[-3] for img in page.get_images(True) if img[-1] == 0]
280c279
<         if self.doc.needsPass:  # check password protection
---
>         if self.doc.needs_pass:  # check password protection
282c281
<         if self.doc.isEncrypted:  # quit if we cannot decrypt
---
>         if self.doc.is_encrypted:  # quit if we cannot decrypt
694c693
<         page = min(page, self.doc.pageCount)  # cannot go beyond last page
---
>         page = min(page, self.doc.page_count)  # cannot go beyond last page
742c741
<         tar_rect = new_rect * ~page.transformationMatrix
---
>         tar_rect = new_rect * ~page.transformation_matrix
745c744
<         cont = bytearray(self.doc.xrefStream(xref))  # modifyable version!
---
>         cont = bytearray(self.doc.xref_stream(xref))  # modifyable version!
750c749
<         self.doc.updateStream(xref, bytes(cont))  # rewrite stream
---
>         self.doc.update_stream(xref, bytes(cont))  # rewrite stream
761d759
<
776c774
<         tar_rect = rect * ~page.transformationMatrix
---
>         tar_rect = rect * ~page.transformation_matrix
779c777
<         cont = bytearray(self.doc.xrefStream(xref))  # modifyable version!
---
>         cont = bytearray(self.doc.xref_stream(xref))  # modifyable version!
781c779
<         self.doc.updateStream(xref, bytes(cont))
---
>         self.doc.update_stream(xref, bytes(cont))
784,785c782,783
<         if not page._isWrapped:
<             page.wrapContents()
---
>         if not page.is_wrapped:
>             page.wrap_contents()
787c785
<         page.cleanContents()
---
>         page.clean_contents()
808c806
<         cont = bytearray(self.doc.xrefStream(xref))  # modifyable version!
---
>         cont = bytearray(self.doc.xref_stream(xref))  # modifyable version!
810,811c808,809
<         self.doc.updateStream(xref, bytes(cont))
<         page.cleanContents()
---
>         self.doc.update_stream(xref, bytes(cont))
>         page.clean_contents()
843c841
<         if self.doc.needsPass or not self.doc.can_save_incrementally():
---
>         if self.doc.needs_pass or not self.doc.can_save_incrementally():
852c850
<         if self.doc.needsPass or not self.doc.can_save_incrementally():
---
>         if self.doc.needs_pass or not self.doc.can_save_incrementally():
862d859
<         self.doc._delXmlMetadata()
883c880
<             page.insertImage(r, filename=path)
---
>             page.insert_image(r, filename=path)
1029c1026
<         if not rect.isInfinite:
---
>         if not rect.is_infinite:
1118c1115
<         pix = page.getPixmap(matrix=self.zoom, alpha=False)
---
>         pix = page.get_pixmap(matrix=self.zoom, alpha=False)
1143c1140
<             if self.doc.isEncrypted:
---
>             if self.doc.is_encrypted:
```
@julian-smith-artifex-com
Copy link
Collaborator

Thanks for this.

Fixed in an independent commit, with a more concise commit message.

@julian-smith-artifex-com
Copy link
Collaborator

Fixed in PyMuPDF-1.21.1 documentation.

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.

None yet

2 participants