Return list of image positions on a page. Args: name: (str, list, int) image identification. May be reference name, an item of the page's image list or an xref. transform: (bool) whether to also return the transformation matrix. Returns: A list of Rect
(page: Page, name, transform=False)
| 722 | |
| 723 | |
| 724 | def get_image_rects(page: Page, name, transform=False) -> list: |
| 725 | """Return list of image positions on a page. |
| 726 | |
| 727 | Args: |
| 728 | name: (str, list, int) image identification. May be reference name, an |
| 729 | item of the page's image list or an xref. |
| 730 | transform: (bool) whether to also return the transformation matrix. |
| 731 | Returns: |
| 732 | A list of Rect objects or tuples of (Rect, Matrix) for all image |
| 733 | locations on the page. |
| 734 | """ |
| 735 | if type(name) in (list, tuple): |
| 736 | xref = name[0] |
| 737 | elif type(name) is int: |
| 738 | xref = name |
| 739 | else: |
| 740 | imglist = [i for i in page.get_images() if i[7] == name] |
| 741 | if imglist == []: |
| 742 | raise ValueError("bad image name") |
| 743 | elif len(imglist) != 1: |
| 744 | raise ValueError("multiple image names found") |
| 745 | xref = imglist[0][0] |
| 746 | pix = Pixmap(page.parent, xref) # make pixmap of the image to compute MD5 |
| 747 | digest = pix.digest |
| 748 | del pix |
| 749 | infos = page.get_image_info(hashes=True) |
| 750 | if not transform: |
| 751 | bboxes = [Rect(im["bbox"]) for im in infos if im["digest"] == digest] |
| 752 | else: |
| 753 | bboxes = [ |
| 754 | (Rect(im["bbox"]), Matrix(im["transform"])) |
| 755 | for im in infos |
| 756 | if im["digest"] == digest |
| 757 | ] |
| 758 | return bboxes |
| 759 | |
| 760 | |
| 761 | def get_text( |
nothing calls this directly
no test coverage detected
searching dependent graphs…