MCPcopy
hub / github.com/datalab-to/marker / get_image

Method get_image

marker/schema/blocks/base.py:128–148  ·  view source on GitHub ↗
(
        self,
        document: Document,
        highres: bool = False,
        expansion: Tuple[float, float] | None = None,
        remove_blocks: Sequence[BlockTypes] | None = None,
    )

Source from the content-addressed store, hash-verified

126 return self._metadata.get(key)
127
128 def get_image(
129 self,
130 document: Document,
131 highres: bool = False,
132 expansion: Tuple[float, float] | None = None,
133 remove_blocks: Sequence[BlockTypes] | None = None,
134 ) -> Image.Image | None:
135 image = self.highres_image if highres else self.lowres_image
136 if image is None:
137 page = document.get_page(self.page_id)
138 page_image = page.get_image(highres=highres, remove_blocks=remove_blocks)
139
140 # Scale to the image size
141 bbox = self.polygon.rescale(
142 (page.polygon.width, page.polygon.height), page_image.size
143 )
144 if expansion:
145 bbox = bbox.expand(*expansion)
146 bbox = bbox.bbox
147 image = page_image.crop(bbox)
148 return image
149
150 def structure_blocks(self, document_page: Document | PageGroup) -> List[Block]:
151 if self.structure is None:

Callers 15

surya_layoutMethod · 0.45
get_all_linesMethod · 0.45
filter_blank_linesMethod · 0.45
extract_imageMethod · 0.45
extract_imageMethod · 0.45
extract_imageMethod · 0.45
__call__Method · 0.45
draw_pdf_debug_imagesMethod · 0.45
__call__Method · 0.45
__call__Method · 0.45

Calls 3

get_pageMethod · 0.80
rescaleMethod · 0.80
expandMethod · 0.80

Tested by

no test coverage detected