MCPcopy Create free account
hub / github.com/Loping151/RoverSign / add_footer

Function add_footer

RoverSign/utils/image.py:37–63  ·  view source on GitHub ↗
(
    img: Image.Image,
    w: int = 0,
    offset_y: int = 0,
    is_invert: bool = False,
    color: Literal["white", "black", "hakush"] = "white",
)

Source from the content-addressed store, hash-verified

35
36
37def add_footer(
38 img: Image.Image,
39 w: int = 0,
40 offset_y: int = 0,
41 is_invert: bool = False,
42 color: Literal["white", "black", "hakush"] = "white",
43):
44 footer = get_footer(color)
45 if is_invert:
46 r, g, b, a = footer.split()
47 rgb_image = Image.merge("RGB", (r, g, b))
48 rgb_image = ImageOps.invert(rgb_image.convert("RGB"))
49 r2, g2, b2 = rgb_image.split()
50 footer = Image.merge("RGBA", (r2, g2, b2, a))
51
52 if w != 0:
53 footer = footer.resize(
54 (w, int(footer.size[1] * w / footer.size[0])),
55 )
56
57 x, y = (
58 int((img.size[0] - footer.size[0]) / 2),
59 img.size[1] - footer.size[1] - 20 + offset_y,
60 )
61
62 img.paste(footer, (x, y), footer)
63 return img

Callers

nothing calls this directly

Calls 1

get_footerFunction · 0.85

Tested by

no test coverage detected