MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / get_image

Method get_image

docling/datamodel/base_models.py:233–254  ·  view source on GitHub ↗
(
        self, scale: float = 1.0, cropbox: Optional[BoundingBox] = None
    )

Source from the content-addressed store, hash-verified

231 ) # Cache of images in different scales. By default it is cleared during assembling.
232
233 def get_image(
234 self, scale: float = 1.0, cropbox: Optional[BoundingBox] = None
235 ) -> Optional[Image]:
236 if self._backend is None:
237 return self._image_cache.get(scale, None)
238
239 if not scale in self._image_cache:
240 if cropbox is None:
241 self._image_cache[scale] = self._backend.get_page_image(scale=scale)
242 else:
243 return self._backend.get_page_image(scale=scale, cropbox=cropbox)
244
245 if cropbox is None:
246 return self._image_cache[scale]
247 else:
248 page_im = self._image_cache[scale]
249 assert self.size is not None
250 return page_im.crop(
251 cropbox.to_top_left_origin(page_height=self.size.height)
252 .scaled(scale=scale)
253 .as_tuple()
254 )
255
256 @property
257 def image(self) -> Optional[Image]:

Callers 9

imageMethod · 0.95
gen_eval_markdownFunction · 0.45
__call__Method · 0.45
__call__Method · 0.45
prepare_elementMethod · 0.45
_populate_page_imagesMethod · 0.45
_parse_page_cellsMethod · 0.45
__call__Method · 0.45
gen_image_and_tableFunction · 0.45

Calls 1

get_page_imageMethod · 0.45

Tested by

no test coverage detected