47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.0 KiB
3.0 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| image_grid | function | py | ml | 1.0.0 | impure | def image_grid(images: list[PIL.Image.Image], cols: int = 4, labels: list[str] | None = None, gap_px: int = 8, bg_color: tuple = (20,20,20)) -> PIL.Image.Image | Combina una lista de PIL Images en un grid NxM con gap configurable, fondo oscuro y labels opcionales sobre cada celda. rows se calcula como ceil(n/cols). Retorna una sola PIL.Image RGB. |
|
false | error_go_core |
|
|
PIL.Image.Image: imagen RGB con el grid montado. Lista con n imagenes en cols columnas y ceil(n/cols) filas. | true |
|
python/functions/ml/tests/test_image_grid.py | python/functions/ml/image_grid.py |
Ejemplo
from PIL import Image
from ml.image_grid import image_grid
from ml.image_save_png import image_save_png
# Generar 6 imagenes de prueba con colores distintos
colors = [(255,0,0),(0,255,0),(0,0,255),(255,255,0),(0,255,255),(255,0,255)]
imgs = [Image.new("RGB", (256, 256), c) for c in colors]
grid = image_grid(
imgs,
cols=3,
labels=["rojo", "verde", "azul", "amarillo", "cyan", "magenta"],
gap_px=10,
bg_color=(30, 30, 30),
)
# grid.size == (3*256 + 4*10, 2*256 + 3*10) == (788, 542)
image_save_png(grid, "outputs/preview_grid.png")
Notas
- Impure: asigna memoria para el canvas y ejecuta
ImageDraw(efectos en objetos PIL internos). Aunque no hace I/O de disco, las allocations PIL y el draw tienen side-effects sobre objetos mutables. - Las imagenes en modo no-RGB (RGBA, L, P, palette) se convierten a RGB
automaticamente con
.convert("RGB")antes de pegar. - Si la lista tiene menos imagenes que
cols * rows, las celdas sobrantes quedan en blanco (solo el color de fondo). - El label usa
ImageFont.load_default()(fuente bitmap monospace de PIL, sin dependencias externas). Para fuentes TTF customizadas usarImageFont.truetype(path, size)externamente y pasar unfontpropio. - Pillow se importa lazy para no bloquear
fn index.