Function
load_rgba_resized
(path: Path, tw: int, th: int)
Source from the content-addressed store, hash-verified
| 88 | |
| 89 | |
| 90 | def load_rgba_resized(path: Path, tw: int, th: int) -> tuple[int, int, bytes]: |
| 91 | with Image.open(path) as im: |
| 92 | im = im.convert("RGBA") |
| 93 | nw, nh = im.size |
| 94 | if tw <= 0 or th <= 0: |
| 95 | raise ValueError("Invalid icon dimensions.") |
| 96 | if (nw, nh) != (tw, th): |
| 97 | im = im.resize((tw, th), Image.Resampling.LANCZOS) |
| 98 | raw = im.tobytes() |
| 99 | return tw, th, raw |
| 100 | |
| 101 | |
| 102 | class IconRef(BaseModel): |
Tested by
no test coverage detected