MCPcopy
hub / github.com/potamides/DeTikZify / expand

Function expand

detikzify/util/image.py:30–33  ·  view source on GitHub ↗

Expand image to a square of size {size}. Optionally trims borders first.

(image, size, do_trim=False, bg="white")

Source from the content-addressed store, hash-verified

28 return image.crop(bbox) if (bbox:=diff.getbbox()) else image
29
30def expand(image, size, do_trim=False, bg="white"):
31 """Expand image to a square of size {size}. Optionally trims borders first."""
32 image = trim(image, bg=bg) if do_trim else image
33 return ImageOps.pad(image, (size, size), color=bg, method=Image.Resampling.LANCZOS)
34
35# based on transformers/image_utils.py (added support for rgba images)
36def load(image: Image.Image | str | bytes, bg="white", timeout=None):

Callers 12

_generate_examplesMethod · 0.90
_generate_examplesMethod · 0.90
preprocessFunction · 0.90
__call__Method · 0.90
process_arxivcapFunction · 0.90
process_openmojiFunction · 0.90
get_vision_featuresMethod · 0.85
updateMethod · 0.85
openMethod · 0.85
updateMethod · 0.85
loadMethod · 0.85
rasterizeMethod · 0.85

Calls 1

trimFunction · 0.85

Tested by

no test coverage detected